daemons
daemons copied to clipboard
Stopping daemon via wrapper script can kill unrelated processes
In v1.2.2 and earlier (at least to 1.1.9), calling 'ruby mydaemon_control.rb stop' can kill one of the invoking user's other processes if the pidfile contains the pid of one of those processes. I was surprised by this when, after trying to stop a daemon that wasn't running, my IDE spontaneously closed.
The issue seems to be that the process is just sent a stop signal without checking to see if it's actually the daemon process we want to stop. (Pidfile cleanup works normally for me, but I don't bother to stop any running daemons before I shut down my dev box, so I tend to get stale pidfiles.) I've solved similar issues in the past by checking the process name (if the process is running) before taking any action on it.