Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site wanginst.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!dcdwest!ittvax!decvax!wanginst!ss From: ss@wanginst.UUCP (Sid Shapiro) Newsgroups: net.unix Subject: Re: getting the pid from the csh - answers Message-ID: <244@wanginst.UUCP> Date: Thu, 14-Feb-85 09:24:45 EST Article-I.D.: wanginst.244 Posted: Thu Feb 14 09:24:45 1985 Date-Received: Sun, 17-Feb-85 04:46:31 EST References: <240@wanginst.UUCP> Distribution: net Organization: Wang Institute, Tyngsboro, Ma. 01879 Lines: 36 > 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 /