Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: csh - how to automatically kill background processes on logout Message-ID: <18913@mimsy.UUCP> Date: 5 Aug 89 19:24:03 GMT References: <72@harald.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 31 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 | ' 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