summaryrefslogtreecommitdiffstats
path: root/usr.bin/killall
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1998-08-30 16:54:58 +0000
committerwosch <wosch@FreeBSD.org>1998-08-30 16:54:58 +0000
commita8c714270019492d83fc0e57e7ec2f3f13df23f4 (patch)
tree1994c0196f9bfaec43b002ccef4db50bf10c44e7 /usr.bin/killall
parent7f39c95951c3336b492e748b93fd3f71c6ba8c65 (diff)
downloadFreeBSD-src-a8c714270019492d83fc0e57e7ec2f3f13df23f4.zip
FreeBSD-src-a8c714270019492d83fc0e57e7ec2f3f13df23f4.tar.gz
PR: bin/5596
Change the diagnostic if there were no matching processes owned by you.
Diffstat (limited to 'usr.bin/killall')
-rwxr-xr-xusr.bin/killall/killall.pl38
1 files changed, 24 insertions, 14 deletions
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";
+ }
}
OpenPOWER on IntegriCloud