Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exclusive lock instead of file presence #5

Open
cableray opened this issue Feb 22, 2019 · 0 comments
Open

Use exclusive lock instead of file presence #5

cableray opened this issue Feb 22, 2019 · 0 comments

Comments

@cableray
Copy link

cableray commented Feb 22, 2019

Take a look at this article: http://www.guido-flohr.net/never-delete-your-pid-file/

Removing a pid file when exiting can cause race conditions because unlinking a file doesn't cause other file handles to be closed immediately. Leaving a file around and getting an exclusive write lock is better.

It might be worth considering if there is a way for this library to reduce the likelihood of race conditions around the PID file, and handle PIDs with an exclusive lock instead of file presence. Additionally, the OS can re-use a PID, so even if a PID is in use, it may belong to a completely different process. However, if a lock is detected on the PID file, then it is more likely that the PID in the file belongs to process that last wrote the PID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant