Race conditions Linux is a multitasking operating system. Other processes will get the CPU while your program is still executing. The validity of any checks you do is suspect, because the state may change. Suggestions Never do checks and actions separately when atomic functions are available. Operate on open files, rather than file names, whenever possible. If you need to do too many checks, there's probably a better way. If you are trying to do stuff as root for other users, better to fork/setuid and do the actions as the other user.