Xref: utzoo comp.lang.perl:417 alt.sources:1530 Path: utzoo!attcan!uunet!shelby!apple!usc!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!littlei!omepd!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl,alt.sources Subject: much better 'killpid' Message-ID: <1990Feb21.181349.21312@iwarp.intel.com> Date: 21 Feb 90 18:13:49 GMT Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 34 After being pummeled by Larry Wall for how ugly my first version was, here's a revised version of killpid, taking advantage of a little common sense *and* some of the nifties in Perl 3.0: Usage is "killpid [pidnumber ...]" #!/local/merlyn/bin/perl $| = 1; @ARGV = sort grep(kill(0, $_), @ARGV); exit 0 if $#ARGV < 0; print "kill -15 @ARGV\n"; kill 15, @ARGV; for (1..5) { sleep 2; @ARGV = grep(kill(0, $_),@ARGV); exit 0 if $#ARGV < 0; } print "kill -9 @ARGV\n"; kill 9, @ARGV; for (1..5) { sleep 2; @ARGV = grep(kill(0, $_),@ARGV); exit 0 if $#ARGV < 0; } print "@ARGV will not die!\n"; exit 1; print reverse split(/\/*/,",rekcah lreP rehtona tsuJ"); -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/