New submission from exarkun <[email protected]>:
`twistd` currently guards against running multiple instances of itself in the same directory (or more accurately, with the same pidfile), since such unintentional concurrent access can have various deleterious consequences, such as data corruption and resource acquisition failure.
However, the way which this is implemented is subject to certain false positives in the form of PID reuse. `twisted.scripts._twistd_unix.checkPID` uses the `ESRCH` failure mode of `os.kill` to determine if another twistd process is still running with the given pidfile. This fails in at least two cases:
* after an unclean shutdown by a previous twistd, a new process is started and is allocated the same pid as is in the pidfile which was left behind. This process now causes twistd to think another twistd process is still running in the directory.
* A large number of versions of Linux appear to allow `os.kill` to be used with kernel thread IDs, not just process IDs. This exacerbates the previous problem by giving each thread of a foreign process the opportunity to collide with the original process ID and break `checkPID`. This is particularly heinous for system services, as they are all started close together, and the chances of a PID collision with a TID is very high.
Various other techniques could be employed to improve the reliability of this checking. For example, a unix socket should reliably reject connections after its owning process has exited. Or, POSIX or advisory locks might be usable, since these should expire when the owning process exits.
----------
Type : enhancement
Component: core
Keywords :
Priority : normal
Nosy :
----------
http://twistedmatrix.com/trac/ticket/3851
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.