Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!topaz!ll-xn!mit-amt!mit-eddie!genrad!decvax!mcnc!ecsvax!bet From: bet@ecsvax.UUCP (Bennett E. Todd III) Newsgroups: net.sources.d Subject: Re: Detecting running processes... this one's portable Message-ID: Date: Wed, 13-Aug-86 09:03:41 EDT Article-I.D.: ecsvax.1919 Posted: Wed Aug 13 09:03:41 1986 Date-Received: Thu, 14-Aug-86 20:24:20 EDT References: Reply-To: bet@ecsvax.UUCP (Bennett E. Todd III) Distribution: net Organization: Duke University Computation Center Lines: 35 Keywords: sleep,kill In article jvc@stl.UUCP (Vic Churchill) writes: > [...] >I would like a way to run a process for a specified time >duration and then "gracefully" zap it. > [...] So something like "fuze foo 30" >has the effect : > __ run foo __________________ eek! >______/ ^ ^ ___ back to shell > \__ sit'n'wait 29 mins | 1min |__/ > / / > a gentle warning / > a killer I had a not entirely unrelated wish: I was trying to debug a program that [1] put the terminal into raw mode (therefore disabling keyboard generated interrupts), and [2] was hanging inextricably. I didn't need to be able to set the time; 2 minutes sufficed. 2 minutes is therefore hardcoded into this shell script; you can rig whatever command parser you want on this (basically trivial) hack. I went through several revisions, the first of which was in fact a ps/grep cludge. This one, based on suggestions from various net readers, seemed to be the cleanest. I call it "timout": ( sleep 120 ; kill -9 $$ ) & exec $* That's it. Settable time parameters, advanced warning before the axe falls, and suchlike "are left as exercises for the reader". It did what I needed. -Bennett -- Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695 UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet