Skip to content

Use exclusive lock instead of file presence #5

@cableray

Description

@cableray

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions