killing bkgnd process on logout

Steve Summit scs at hstbme.mit.edu
Mon Sep 4 03:21:25 AEST 1989


In article <128 at isgtec.UUCP> bmw at isgtec.UUCP (Bruce Walker) writes:
>You are supposed to start it like this (usually from .login):
>	$ checkmail&
>However, if you do this [under certain job-control csh's], the process
>disconnects from your tty and continues running (inherited by root).
>
>My (slightly klugey) solution is to add a line to my .logout (csh):
>	/bin/kill -9 `ps x | awk '$5=="checkmail" {print $1}'`&
>Anyone know a better way?

In article <92 at harald.UUCP> jba at harald.ruc.dk (Jan B. Andersen)
correctly points out that:

>...TFM... says it all:
>     CSH(1B)
>	  Processes running in background (by &) are immune to signals
>	  generated from the keyboard, including hangups.
>
>Personally I find this behavior a bit odd. Why not use nohup(1)
>instead?

I consider this a bug in csh, though most doubtless consider it a
feature.  In the old days, it was considered the exception that a
background job would want to be left running after logout;
therefore, the HUP signal normally killed all processes, and
nohup had to be used explicitly when a background job was to be
left running.  (nohup also attempted to guarantee, in a
simpleminded but effective way, that the background job would not
scribble on the terminal, out of courtesy for the next person to
log in on it.  Now that "everybody" uses csh, nobody uses nohup
and this protection has disappeared, which was probably one
reason Berkeley had to invent vhangup, about which the inimitable
Chris Torek has said, "warning: don't look at [it] immediately
after eating food.")

Would one of the innumerable csh users and/or lovers out there
let this poor fellow know what the appropriate way of having
background demons killed on logout under csh is?  (There is an
appropriate, clean way, right?)

                                                Steve Summit



More information about the Comp.unix.wizards mailing list