Sophie

Sophie

distrib > Mandriva > 2009.1 > i586 > media > main-release-src > by-pkgid > 3837d6e6d6e4fc5e03616d6e4e2ddc8c > files > 3

sysvinit-2.86-11mdv2009.1.src.rpm

diff -Naurp sysvinit-2.86/man/killall5.8 sysvinit-2.86.oden/man/killall5.8
--- sysvinit-2.86/man/killall5.8	2004-06-09 14:47:45.000000000 +0200
+++ sysvinit-2.86.oden/man/killall5.8	2008-12-22 16:32:38.000000000 +0100
@@ -10,6 +10,10 @@ is the SystemV killall command. It sends
 kernel threads and the processes in its own session, so it won't kill
 the shell that is running the script it was called from. Its primary
 (only) use is in the \fBrc\fP scripts found in the /etc/init.d directory.
+.SH EXIT STATUS
+The program return zero if it killed processes.  It return 2 if no
+process were killed, and 1 if it was unable to find any processes
+(/proc/ is missing).
 .SH SEE ALSO
 .BR halt (8),
 .BR reboot (8)
diff -Naurp sysvinit-2.86/src/killall5.c sysvinit-2.86.oden/src/killall5.c
--- sysvinit-2.86/src/killall5.c	2008-12-22 16:32:23.000000000 +0100
+++ sysvinit-2.86.oden/src/killall5.c	2008-12-22 16:32:38.000000000 +0100
@@ -595,6 +595,9 @@ int main(int argc, char **argv)
 	int		pid, sid = -1;
 	int		sig = SIGKILL;
 
+	/* return non-zero if no process was killed */
+	int		retval = 2;
+
 	/* Get program name. */
 	if ((progname = strrchr(argv[0], '/')) == NULL)
 		progname = argv[0];
@@ -635,15 +638,17 @@ int main(int argc, char **argv)
 	/* Read /proc filesystem */
 	if (readproc() < 0) {
 		kill(-1, SIGCONT);
-		exit(1);
+		return(1);
 	}
 
 	/* Now kill all processes except init (pid 1) and our session. */
 	sid = (int)getsid(0);
 	pid = (int)getpid();
 	for (p = plist; p; p = p->next)
-		if (p->pid != 1 && p->pid != pid && p->sid != sid && !p->kernel)
+		if (p->pid != 1 && p->pid != pid && p->sid != sid && !p->kernel) {
 			kill(p->pid, sig);
+			retval = 0;
+		}
 
 	/* And let them continue. */
 	kill(-1, SIGCONT);
@@ -651,5 +656,5 @@ int main(int argc, char **argv)
 	/* Done. */
 	closelog();
 
-	return 0;
+	return retval;
 }