ss@wanginst.UUCP (Sid Shapiro) (02/14/85)
> So I cheerfully set off to try and figure out how to capture the pid > that is returned when you type foo& I have had three replies. One that I had a little trouble relating to my question, so I won't bother repeating it. The second was from an unnamed person (I don't want to embarrass him) who cheerfully told me about a shell variable that got set in his shell, but not mine - (he didn't realize that his shell had been hacked in that way). And the third from wizard Spencer Thomas (thomas@utah-cs.ARPA). Spencer's was the most useful (no surprise there): > > Here is an alias we use to kill off selected or all jobs. Works sort > > of, most of the time. But, it does show how to get the (in this case) > > job id's of all your background or stopped tasks (the hard part is in > > /usr/local/killall, included below). The '%!$' at the end is to > > continue processes (such as Gosling emacs) that want to print something > > before they die. If a subprocess doesn't die on SIGTERM (e.g., a > > shell), this won't work correctly. > > > > alias res 'if ("\!$" == "*") source /usr/local/killall;'\ > > 'if ("\!$" != "*") kill %\!$; if ("\!$" != "*") %\!$' > > > > # kill all subprocesses of this shell. > > # > > jobs >~/.pcs > > foreach i (`sed 's/.*\[\(.*\)\].*/\1/' ~/.pcs`) > > res $i > > end With one mimor mod for me to pick up just the job I want killed, this worked like gangbusters. The only thing that puzzles me is that I tried some combinations of sed scripts originally a few months ago when I started this business and I had trouble - of course I don't remember what the trouble was... Oh well. Thanks for all your help, folks. / Sid /