It was observed that chef-client init.d stop service is killing process id of some other process. The code snippet shows that it usage killproc function of init.d on rhel 6 but only considering the PID from file not considering the program path.
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $exec
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
If you put any other process id of some other process suppose which were allocated by OS when chef-client was not running then this killproc will kill that process while it should also recognize the "/usr/bin/chef-client".
Description
It was observed that chef-client init.d stop service is killing process id of some other process. The code snippet shows that it usage killproc function of init.d on rhel 6 but only considering the PID from file not considering the program path. stop() { echo -n $"Stopping $prog: " killproc -p $pidfile $exec retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval }
killproc -p /var/tmp/test.pid /usr/bin/chef-client
If you put any other process id of some other process suppose which were allocated by OS when chef-client was not running then this killproc will kill that process while it should also recognize the "/usr/bin/chef-client".
Related Issue
https://github.com/chef/customer-bugs/issues/221
Replication Case
Expected behaviour
make sure that the init script does not kill anything not belonging to chef processes
Actual behaviour
Non-chef processes are being killed on init stop
Additional context
Please find the script snippet below: