Wrong Handling of pid files (example: fcgiwrap) forces single user mode. Am I correct?

BBlister bblister at gmail.com
Fri Jun 2 15:48:51 UTC 2017


I filled a report


If you issue onestart the bug is not triggered.

Also, the bug with onerestart is not triggered all the time. For example, if
you do 

rm /var/run/fcgiwrap/fcgiwrap.pid

and then issue as root from the shell:

/usr/local/etc/rc.d/fcgiwrap onerestart

then you see usually: 

cat: /var/run/fcgiwrap/fcgiwrap.pid: No such file or directory
Stopping fcgiwrap.
kill: illegal process id: -
Starting fcgiwrap.

But, there is a race condition, because if you do a number of times:

rm /var/run/fcgiwrap/fcgiwrap.pid

and then debug the rc script with:

rm /var/run/fcgiwrap/fcgiwrap.pid ; bash -x /usr/local/etc/rc.d/fcgiwrap

you will eventually hit the single user mode, because the PID 1 is somewhere
in the list:

kill -TERM -- - 1 17009 17607 17654 1 1 1 1 1 86584 4245 5166 5929 80402

if it is the first one like the previous example, then it will hit user mode
immediately, otherwise the script may exit first before hitting the PID 1,

kill -TERM -- - 17009 17607 17654 1 1 1 1 1 86584 4245 5166 5929 80402 86559

View this message in context: http://freebsd.1045724.x6.nabble.com/Wrong-Handling-of-pid-files-example-fcgiwrap-forces-single-user-mode-Am-I-correct-tp6189171p6189230.html
Sent from the freebsd-questions mailing list archive at Nabble.com.

More information about the freebsd-questions mailing list