jba@harald.ruc.dk (Jan B. Andersen) (08/05/89)
In Bourne shell background processes started with '&' will automatically get killed on logout (hangup). But the man page for csh says: "Processes running in the background (by &) are immune to to signals... including hangups." How do I enable SIGHUP? In .logout? Should I kill them instead? -- Jan B. Andersen ("SIMULA does it with CLASS")
chris@mimsy.UUCP (Chris Torek) (08/06/89)
In article <72@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen) writes: >In Bourne shell background processes started with '&' will automatically >get killed on logout (hangup). But the man page for csh says: "Processes >running in the background (by &) are immune to to signals... including >hangups." > >How do I enable SIGHUP? In .logout? Should I kill them instead? Right: % cat .logout tf=/tmp/k$$ jobs >$tf if (! -z $tf) then # there are jobs jobs >$tf.1 # rerun it to dump `Done' jobs grep -v Stopped <$tf.1 >$tf; rm $tf.1 # cannot use a pipe here if (! -z $tf) then # there are running jobs eval `echo kill -1; sed 's/.\([0-9]*\).*/%\1/' <$tf` endif endif rm $tf Warning: I have not tested this and it may run afoul of various csh quirks. The important trick is to run `jobs >file', not `jobs | command', as the latter runs `jobs' in a subshell and thus produces no output (although `jobs | <any-csh-builtin>' is good for a laugh :-) ). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
jik@athena.mit.edu (Jonathan I. Kamens) (08/07/89)
Or, if you don't mind killing all of the processes owned by you instead of just the ones you started from your login shell, you can just do "kill -HUP -1" in newer BSD systems. Everything will get the HUP signal. This is also useful if you're on an X workstation and your login xterm dies somehow but doesn't log you out. "kill -9 -1" does a pretty good job of terminating the login session quickly :-). Jonathan Kamens USnail: MIT Project Athena 432 S. Rose Blvd. jik@Athena.MIT.EDU Akron, OH 44320 Office: 617-253-4261 Home: 216-869-6432