Are fopen/fread/fgets PID-safe in C ?
- by Jane
Various users are browsing through a website 100% programmed in C (CGI). Each webpage uses fopen/fgets/fread to read common data (like navigation bars) from files. Would each call to fopen/fgets/fread interefere with each other if various people are browsing the same page ? If so, how can this be solved in C ? (This is a Linux server, compiling is done with gcc and this is for a CGI website programmed in C.)
Example:
FILE *DATAFILE = fopen(PATH, "r");
if ( DATAFILE != NULL )
{
while ( fgets( LINE, BUFFER, DATAFILE ) )
{
/* do something */
}
}