Problem stopping a program
Paul Schmehl
pauls at utdallas.edu
Wed Mar 29 02:32:57 UTC 2006
I'm working on a new port that uses a tcl script in daemon mode. I've
written an rc.d script to start and stop the daemon, and I'm having a
problem stopping the daemon. If I do it immediately, it stops just fine,
but if I leave the daemon running for a while, I cannot. (The daemon
spawns two child processes after it's started.)
Here's an example: /usr/local/etc/rc.d/sguild.sh restart
Stopping sguild
Waiting for PIDS: 4554 4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558
4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559, 4554
4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559,
4554 4558 4559,
This will go on indefinitely. If I kill the process and then try
restarting again, the child processes are gone, but the parent process is
not.
bash-2.05b# /usr/local/etc/rc.d/sguild.sh restart
Stopping sguild
Waiting for PIDS: 4554, 4554, 4554^C
bash-2.05b# /usr/local/etc/rc.d/sguild.sh restart
Stopping sguild
Waiting for PIDS: 4554, 4554^C
However, if I kill the (rc.d) process and then try to kill the daemon from
the cli, it dies immediately.
bash-2.05b# ps -auxw | grep sguild
root 4554 0.0 0.7 3636 2744 p0- I 11:21PM 0:00.08
/usr/local/bin/tclsh8.4 /usr/local/bin/sguild -D -c /usr/local/etc/s
root 34417 0.0 0.2 1408 732 p0 R+ 2:20AM 0:00.00 grep sguild
bash-2.05b# kill -9 4554
bash-2.05b# ps -auxw | grep sguild
root 34419 0.0 0.1 1408 568 p0 R+ 2:20AM 0:00.00 grep sguild
Here's the stop_cmd section of the script. (I had to write this because
the standard rc.d script couldn't find the process because the cli is
/usr/local/bin/tclsh8.4 /usr/local/bin/sguild.)
sguild_stop() {
if [ -z "${pids}" ]; then
echo "${name} not running?"
else
echo "Stopping ${name}"
kill -${sig_stop:-TERM} ${pids}
wait_for_pids ${pids}
fi
}
I've tried using KILL instead of TERM, but it doesn't make any difference.
Any idea what's wrong?
Paul Schmehl (pauls at utdallas.edu)
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/
More information about the freebsd-ports
mailing list