I have a C application that occasionally fails to open a file which is stored on a /tmp
share.
Here is the relevant chunk of code:
// open file and start parsing
notStdin = strcmp(inFile, "-");
if (notStdin) {
coordsIn = fopen(inFile, "r"); <----- inFile = file that I want to open
if (coordsIn == NULL) {
fprintf(stderr, "ERROR: Could not open coordinates file: %s\n\t%s\n", inFile, strerror(errno));
exit(EXIT_FAILURE);
}
}
else
coordsIn = stdin;
Once out of eight to ten trials, I get a NULL
FILE pointer. Here is an example error message:
ERROR: Could not open coordinates file: /tmp/coordinates.txt
File or directory does not exist
However, the file /tmp/coordinates.txt
does indeed exist, as I can open it with standard utilities like head
, cat
or more
, etc.
The permissions of different /tmp/coordinates.txt
trial files are the same.
Here is the result from uname -a
:
$ uname -a
Linux hostname 2.6.18-128.2.1.el5 #1 SMP Wed Jul 8 11:54:47 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
If I use a different inFile
that is stored in a different, non-/tmp
share, then I do not observe this symptom.
Is there anything that would cause fopen()
to fail on a file stored in the /tmp
share? Are there other troubleshooting steps I can pursue?