Are fopen/fread/fgets PID-safe in C ?

Posted by Jane on Stack Overflow See other posts from Stack Overflow or by Jane
Published on 2010-04-12T23:46:00Z Indexed on 2010/04/12 23:52 UTC
Read the original article Hit count: 351

Filed under:
|
|
|
|

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 */
    }
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about cgi