Killing background processes at logout (AGAIN)
bernerus at chalmers.UUCP
bernerus at chalmers.UUCP
Sat Dec 15 06:50:30 AEST 1984
Since there were absolutely NO response to my article a few weeks ago
I will send it again if something went wrong somewhere:
-------------
I'm trying to write a new 'remind' program (a program that once in a
while tells me things). The reason is that I was tired of the old one
that wanted me to put in a message that fit the mandatory "You have to ..."
or "You're going to be late to...', and English isn't my native language.
I looked at the old program and gave up in a few minutes. It was almost
impossible to understand and terribly unstructured.
Now to the problem:
The remind program wakes up once every 100 sec's or so to see if it
should terminate or maybe do something else. When it does it has to
calculate the length of the next sleeping period. While doing that it
consumes cpu power that could be used for something more useful,
especially when almost every user here runs about 3 remind's
simultaneously and we are normally 25-30 users logged on.
So I asked myself: Why not let the background process sleep for 14400
seconds (4 hours) or whatever appropriate and then wake up to remind
about things. There is just one problem with this: When I log out, the
process is no longer useful and should be terminated.
The question is: Is there a nice way to implement this functionality
i.e. killing a background process when my csh dies.
The first approach was setting the background process' process group
the same as the csh's. In this way, the HUP signal (from the dh or dz
driver) would be distributed to the remind process as well. This
worked fine ... almost. The problem seems to be that csh changes its
process group whenever a program is run in the foreground. If I hang
up (or something forces me to) when the csh's process group is changed,
the remind process won't get the HUP signal.
Another problem is that the remind program normally isn't started by
csh but by the program 'calend'; the csh's process group is not the
father process'.
I can't find a way to make a child be dependent on its parent (or one
of its grand parents) in a nice way. Is there any wizard out there who
can give me a hint on how to do it?
Chris. ...!mcvax!enea!chalmers!bernerus
More information about the Comp.unix.wizards
mailing list