From a8c714270019492d83fc0e57e7ec2f3f13df23f4 Mon Sep 17 00:00:00 2001 From: wosch Date: Sun, 30 Aug 1998 16:54:58 +0000 Subject: PR: bin/5596 Change the diagnostic if there were no matching processes owned by you. --- usr.bin/killall/killall.pl | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'usr.bin/killall') diff --git a/usr.bin/killall/killall.pl b/usr.bin/killall/killall.pl index 098f08b..9ad1f5d 100755 --- a/usr.bin/killall/killall.pl +++ b/usr.bin/killall/killall.pl @@ -26,7 +26,7 @@ # # killall - kill processes by name # -# $Id: killall.pl,v 1.8 1997/02/22 19:55:24 peter Exp $ +# $Id: killall.pl,v 1.9 1998/01/01 17:24:43 wosch Exp $ $ENV{'PATH'} = '/bin:/usr/bin'; # security @@ -84,18 +84,24 @@ foreach (sort{$a <=> $b} grep(/^[0-9]/, readdir(PROCFS))) { # quote meta characters ($programMatch = $program) =~ s/(\W)/\\$1/g if $match; - if ( # match program name - ($proc[$PROC_NAME] eq $program || - ($match && $proc[$PROC_NAME] =~ /$programMatch/i) - ) && - # id test - ($proc[$PROC_EUID] eq $id || # effective uid - $proc[$PROC_RUID] eq $id || # real uid - !$id)) # root - { - push(@kill, $pid) if !$pidu{"$pid"}; - $pidu{"$pid"} = $pid; - $thiskill{"$program"}++; + # match program name + if ($proc[$PROC_NAME] eq $program || + ($match && $proc[$PROC_NAME] =~ /$programMatch/i)) { + + # id test + if ($proc[$PROC_EUID] eq $id || # effective uid + $proc[$PROC_RUID] eq $id || # real uid + !$id) # root + { + push(@kill, $pid) if !$pidu{"$pid"}; + $pidu{"$pid"} = $pid; + $thiskill{"$program"}++; + } + + # process exists, but does not belong to you + else { + $notkillable{"$program"}++; + } } } } @@ -105,7 +111,11 @@ closedir PROCFS; # nothing found foreach $program (@ARGV) { - warn "No matching processes ``$program''\n" unless $thiskill{"$program"}; + if (!$thiskill{"$program"}) { + print STDERR "No matching processes ``$program''"; + print STDERR " belonging to you" if $notkillable{"$program"}; + print STDERR "\n"; + } } -- cgit v1.1