Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Killing the correct process Message-ID: <5724@star.cs.vu.nl> Date: 2 Mar 90 00:00:44 GMT References: <22332@adm.BRL.MIL> <5312@star.cs.vu.nl> <1212@root44.co.uk> <5352@star.cs.vu.nl> <1221@root44.co.uk> <5448@star.cs.vu.nl> <1381@root44.co.uk> <5669@star.cs.vu.nl> <1813@root44.co.uk> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, the Netherlands Lines: 67 In article <1813@root44.co.uk>, gwc@root.co.uk (Geoff Clare) writes: )... )Glad to hear you've seen the light (at last :-). My original script explored the (portable/V7) sh boundaries. I wanted to distinguish between someone *else* killing the job and *timeout* killing it; this was the purpose of the `-v' option (I know, there's a race condition); as `timeout -v' already told me the job had timed out, I didn't want the shell's `Killed' message; therefore I diddled with file descriptor 2; as I wanted a synchronous message I had to invoke an `sh -c' to do the real work; to kill a leftover sleep I had to use the backquote construct. )Your new script is the same as mine with one worthwhile addition and a )few rather less useful (IMHO) ones. Thanks for saving me the effort of )implementing my suggested method for tidying up the leftover sleep. There's still a better way, something like: for t in $timeout $delay do while test $t -gt $interval do sleep $interval kill -0 $$ || exit t=`expr $t - $interval` done sleep $t kill $SIG $$ && kill -0 $$ || exit SIG=-KILL done )... )SIGHUP: you might want to do a "nohup timeout somecommand ... &" ^^^^^ Indeed. )SIGALRM: is not for "timing out" a process, it's for use by a process, e.g. ) for timing out a system call or for sleeping. If the process is ) using SIGALRM, all your "time out" will do is wake it up early. In general you're right; however, is it inconceivable that the process has been especially configured to cleanup on reception of a SIGALRM? )SIGXCPU: is for limiting resource usage, and in any case is non-standard. So what? From `man init' on SunOS 4.0.3c: init catches the hangup signal (SIGHUP) and interprets it to mean that the file /etc/ttytab should be read again. "Boo hiss! SIGHUP is for signaling a hangup on a terminal line!" )The phrase "time out" when applied to a process really means "terminate )before normal completion". When you want to *TERM*inate a process you use )SIG*TERM*. Need I say more? "No. You need to say less." -- Richard Sexton, richard@gryphon.COM Couldn't resist! :-) The phrase "time out" when applied to a process really means "kill before normal completion". When you want to *KILL* a process you use SIG*KILL*. Sic! -- "Belfast: a sentimental journey to the Dark Ages - Crusades & Witchburning - Europe's Lebanon - Book Now!" | maart@cs.vu.nl, uunet!mcsun!botter!maart