有时还是很有必要的:

#include <unistd.h>
#include <fcntl.h>

int access(const char *pPath, int mode);   

F_OK:文件是否存在
R_OK:读
W_OK:写
X_OK:执行

#define LOCK_FILE "quantum6.lock"

    if (access(LOCK_FILE, W_OK) != -1)   
    {   
        printf("%s can write.\n", LOCK_FILE);   
    }   
    else  
    {   
        printf("%s can not write.\n", LOCK_FILE);   
    }