ITEM: D8757L
Parent process dies & child finishes before dying
Question:
Our situation is as follows:
User logs in and their $HOME/.profile is run. $HOME/.profile
starts up an application. Once the application is exited the
user is returned to his .profile which immediately exits.
The problem is that the application starts a script to scan for
email. This script contains a sleep call so that it checks for
email every hour. When the user exits, this sleep can hang around
for up to an hour after he's logged off. With over 120 users this
adds up to a lot of orphaned processes...
Since a lot of the users log in as the same user id, we need to
be careful how we kill these orphaned processes...
Any suggestions on how to kill the sleep process when the user
logs out?
Response:
Try adding code similar to the following to each effected user's
$HOME/.profile, just before the exit statement:
PID=`jobs -l | cut -f3 -d' '`
PGID=`ps -F '%r' -p $PID`
kill -9 -$PGID
NOTE: I didn't use the "jobs -p" command because this sometimes
returns a process id of 0 even if the command is still
running. In this situation, the command is listed as
"unknown". With "jobs -l", this problem does not occur;
even if the command is listed as "unknown" a process id
will be given.
Support Line: Parent process dies & child finishes before dying ITEM: D8757L
Dated: September 1993 Category: N/A
This HTML file was generated 99/06/24~13:30:55
Comments or suggestions?
Contact us