Recent

Author Topic: [CLOSED] Temp file CGI00000.TMP  (Read 379 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1800
[CLOSED] Temp file CGI00000.TMP
« on: May 17, 2026, 06:40:45 am »
With my CGI application, when I upload file from webbrowser, the file seems to be saved temporarily at c:\windows\temp directory with file name CGIxxxxx.TMP, the number increased at every case. The problem is when I recompile the CGI webserver program, then the file name starts with CGI00000.TMP and there occurs error --- cannot save file.
So I have to delete the files whenever I recompile the cgi web server. Are there any way --- for example, forcing overwriting?   
« Last Edit: May 20, 2026, 05:15:25 am by egsuh »

egsuh

  • Hero Member
  • *****
  • Posts: 1800
Re: Temp file CGI00000.TMP
« Reply #1 on: May 17, 2026, 07:19:24 am »
I think it's not recompile. Rebooting server.

LeP

  • Sr. Member
  • ****
  • Posts: 348
Re: Temp file CGI00000.TMP
« Reply #2 on: May 17, 2026, 09:14:49 am »
This came for google search:
Quote
A cgixxx.tmp file is a temporary file automatically generated by a web server (like Apache or IIS) when processing Common Gateway Interface (CGI) scripts. The "xxx" usually represents random characters or a process ID. It holds data temporarily while a script runs, and is typically deleted automatically.
Because temporary files sometimes get "stuck" if a process crashes or is interrupted, you may occasionally find them lingering on your system.

So, may be your cgi app is not configured correctly ?
Un Sistema per domarli, un IDE per trovarli, un codice per ghermirli e nel framework incatenarli.
An operating system to tame them, an IDE to find them, a code to catch them and in the framework chain them.

rvk

  • Hero Member
  • *****
  • Posts: 7045
Re: Temp file CGI00000.TMP
« Reply #3 on: May 17, 2026, 09:30:25 am »
The problem is when I recompile the CGI webserver program, then the file name starts with CGI00000.TMP and there occurs error --- cannot save file.
That's probably each time you start the browser. The cgi doesn't have a clue with what number to start.

So you programmed it to start on 0???

So either save the progress and load it on startup and start from there, or detect where you left (when saving and the file exists skip to the next), or use real random number. But when using random numbers you would still need to detect if a file already exists.

Why are you saving in c:\windows\temp. I don't think it's the correct place anymore. %temp% is the correct place nowadays. Also... windows had an API call to create a unique temporary filename (guaranteed to be unique and non existing). Why not use that?


Thaddy

  • Hero Member
  • *****
  • Posts: 19278
  • Glad to be alive.
Re: Temp file CGI00000.TMP
« Reply #4 on: May 17, 2026, 09:32:16 am »
It is not the cgi, it is the server software that causes this. As LeP wrote already.
The server should delete the temp when the client session ends. Not the cgi.
All major webserver software does this automatically in their standard configuration.
« Last Edit: May 17, 2026, 09:35:25 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

egsuh

  • Hero Member
  • *****
  • Posts: 1800
Re: Temp file CGI00000.TMP
« Reply #5 on: May 20, 2026, 05:15:07 am »
Thank you for all the comments. I searched and AI says the temp files are automatically deleted after the request has been processed, but not deleted in practice.

The IIS_USER was given access rights of read and write to TEMP folder, but not modify. And AI explains it might be the reason. So I added modification right to the IIS_USER but still the temp files are not deleted.

This does not cause any problem right now unless I restart the server, so I'd like to look over it. If still it doesn't work, I'll consider deleting the tempfile within my webserver application.


Thaddy

  • Hero Member
  • *****
  • Posts: 19278
  • Glad to be alive.
Re: [CLOSED] Temp file CGI00000.TMP
« Reply #6 on: May 20, 2026, 06:04:41 am »
You did not mention that you are not only using CGI, but also your webserver application, i.e. your own server software?
Is that webserver also a FPC application?
From there we can evaluate what is happening, in this case not happening.
For example: Is it derived from TFPHttpServer? There have been a couple of changes between 3.2.2 and trunk regarding session management, but only for session cookies. This may be related.

I am also running some FPC based servers on my Raspberry Pi farm, so I am happy to debug that issue.

What exactly is your server software? I can also help with Apache, but that deletes session files by default.
« Last Edit: May 20, 2026, 06:11:59 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

egsuh

  • Hero Member
  • *****
  • Posts: 1800
Re: [CLOSED] Temp file CGI00000.TMP
« Reply #7 on: May 26, 2026, 04:37:18 am »
My webserver is purely written Lazarus. I'm running both CGI and FCGI programs (the same program). They are interchangeable, as both share the same database.
CGI0000... files are created when I post file.

rvk

  • Hero Member
  • *****
  • Posts: 7045
Re: [CLOSED] Temp file CGI00000.TMP
« Reply #8 on: May 26, 2026, 10:05:30 am »
My webserver is purely written Lazarus. I'm running both CGI and FCGI programs (the same program). They are interchangeable, as both share the same database.
CGI0000... files are created when I post file.
Just like  said earlier... if you programmed the webserver yourself (or use existing code) then look at the code where the temp file is created. It starts at 0 each time the webserver is restarted. You need to check if there is already a 0, and 1, 2, 3 etc. and start at the last used number + 1. Otherwise you need to remove the 0 before reusing that temp file.

This is not a problem in your CGI but in the webserver-code.

Also... I wouldn't use C:\Windows\Temp hardcoded (if that's the case) unless the program itself runs as service and %TEMP% returns C:\Windows\Temp.

egsuh

  • Hero Member
  • *****
  • Posts: 1800
Re: [CLOSED] Temp file CGI00000.TMP
« Reply #9 on: May 26, 2026, 11:19:52 am »
Quote
ust like  said earlier... if you programmed the webserver yourself (or use existing code) then look at the code where the temp file is created. It starts at 0 each time the webserver is restarted. You need to check if there is already a 0, and 1, 2, 3 etc. and start at the last used number + 1. Otherwise you need to remove the 0 before reusing that temp file.

This is not a problem in your CGI but in the webserver-code.

Also... I wouldn't use C:\Windows\Temp hardcoded (if that's the case) unless the program itself runs as service and %TEMP% returns C:\Windows\Temp.


Yes, I found it's Windows issue, not CGI program's issue.
c:\windows\temp is the default folder by Windows (or IIS?) itself.

From the google, the temp files should be erased automatically, but not done yet.
So I'll check for this issue first, and then delete the files within my own program.
Anyway not a big inconvenience.

 

TinyPortal © 2005-2018