Skip to main content

Module single_instance

Module single_instance 

Source
Expand description

Single-instance supervision: the exclusive socket bind is the lock.

Binding the control socket fails with EADDRINUSE when the path is already occupied. We then ping it: a live daemon answers (so we refuse to start a second), while a stale socket left by a crashed daemon does not (so we reclaim it and rebind).

The socket is bound owner-private (0600) from birth: [bind_private] tightens the process umask across the bind so the inode is never created group/world-accessible. This closes the window a post-bind chmod would leave open, so the file mode no longer depends on the parent directory already being 0700. See issue #995.

Functionsยง

bind_or_reclaim
Binds the control socket, reclaiming a stale socket from a crashed daemon but refusing to displace a live one.