[alt.sources] much better 'killpid'

merlyn@iwarp.intel.com (Randal Schwartz) (02/22/90)

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!"=/