Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Mar 2006 20:31:43 -0600
From:      Paul Schmehl <pauls@utdallas.edu>
To:        freebsd-ports@freebsd.org
Subject:   Problem stopping a program
Message-ID:  <6F8EC8DCFAC4D47258FEF35B@Paul-Schmehls-Computer.local>

next in thread | raw e-mail | index | archive | help
--==========32D7C57CE3DEF499E594==========
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'm working on a new port that uses a tcl script in daemon mode.  I've=20
written an rc.d script to start and stop the daemon, and I'm having a=20
problem stopping the daemon.  If I do it immediately, it stops just fine,=20
but if I leave the daemon running for a while, I cannot.  (The daemon=20
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=20
4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559, 4554 4558 4559,=20
4554 4558 4559,

This will go on indefinitely.  If I kill the process and then try=20
restarting again, the child processes are gone, but the parent process is=20
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=20
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=20
/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=20
the standard rc.d script couldn't find the process because the cli is=20
/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.=20
Any idea what's wrong?

Paul Schmehl (pauls@utdallas.edu)
Adjunct Information Security Officer
University of Texas at Dallas
AVIEN Founding Member
http://www.utdallas.edu/
--==========32D7C57CE3DEF499E594==========--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6F8EC8DCFAC4D47258FEF35B>