util: dear future reader, don't try to kill init this way

The chances that this gets fed a garbage value has potential to
be close to 1, but we are quite fond of our little init so if this
is needed do it the manual way (as it is already done, at least
for HUP).
This commit is contained in:
Franco Fichtner 2017-03-03 21:02:22 +01:00
parent 844d6b506a
commit b8c9eb4711

View File

@ -43,7 +43,7 @@ function killbypid($pidfile, $sig = 'TERM', $waitforit = false)
{
if (isvalidpid($pidfile)) {
mwexecf('/bin/pkill -%s -F %s', array($sig, $pidfile));
} elseif (is_numeric($pidfile) && $pidfile > 0) {
} elseif (is_numeric($pidfile) && $pidfile > 1) {
mwexecf('/bin/kill -%s %s', array($sig, $pidfile));
} else {
return;
@ -62,7 +62,7 @@ function isvalidpid($pidfile)
{
if (file_exists($pidfile)) {
return mwexecf('/bin/pgrep -nF %s', $pidfile, true) == 0;
} elseif (is_numeric($pidfile) && $pidfile > 0) {
} elseif (is_numeric($pidfile) && $pidfile > 1) {
return mwexecf('/bin/kill -0 %s', $pidfile, true) == 0;
}