Just to make this more obvious (and so search engines find this easier):

If you do fileops of any kind outside of PHP (say via a system() call), you probably want to clear the stat cache before doing any further tests on the file/dir/whatever. For example:

<?php// is_dir() forces a stat call, so the cache is populatedif( is_dir($foo) ) {system("rm -rf " . escapeshellarg($foo)); if( is_dir($foo) ) {// ...will still be true, even if the rm succeeded, because it's just // reading from cache, not re-running the stat()}}?>

Pop a clearstatcache() after the system call and all is good (modulo a bit of a performance hit from having a cleared stat cache :-( ).

On Linux, a forked process inherits a copy of the parent's cache, but after forking the two caches do not impact each other. The snippet below demonstrates this by creating a child and confirming outdated (cached) information, then clearing the cache, and getting new information.