Wednesday, 1 May 2019

Apache holds file lock on PHP file until closed

I have a PHP script that is dynamically created by my application, (Just an fwrite inside the www folder of Apache. Note: Apache is running while this is happening

). The application then pings the script using curl, the script throws an error and dies (as intended. Note: I can confirm the script is finishing cleanly by hitting it with my browser and it returning the response in a reasonable amount of time).

During this install, for unknown reasons, Apache creates a file handle to this specific file. This handle is only freed when Apache is shut down.

My issue is that if I try to delete that file now, it is locked and it's permissions seem broken (Windows saying access denied for any commands on it, I don't even have read access on the permissions so I have no idea how messed up the permissions have become).

When Apache is closed it obviously frees this lock, and due to my application trying to remove the file but failing, the file is then deleted immediately from the previous failed delete now the lock is free.

I also have cygwin installed which can sometimes cause weird issues with files but doesn't seem to be the culprit this time.

Any ideas of what could be causing this behaviour? Other similar scripts that are generated and used the same way work absolutely fine.

Note: This only happens on windows, On Linux the program is still run from Windows, but performs all it's file activity with SFTP



from Apache holds file lock on PHP file until closed

No comments:

Post a Comment