File sysvinit-2.82-startstop.patch of Package sysvinit

--- contrib/start-stop-daemon.c
+++ contrib/start-stop-daemon.c	Wed Feb 14 13:38:07 2001
@@ -3,6 +3,7 @@
  * in C (faster - it is executed many times during system startup).
  *
  * Written by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>,
+ * modified by Raymund Will <ray@lst.de>,
  * public domain.
  */
 
@@ -13,12 +14,13 @@
 #include <signal.h>
 #include <errno.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <pwd.h>
 
-#define VERSION "version 0.3, 1996-06-05"
+#define VERSION "version 0.3.1, 1996-07-19"
 
 static int testmode = 0;
 static int quietmode = 0;
@@ -28,9 +30,8 @@
 static int signal_nr = 15;
 static int user_id = -1;
 static const char *userspec = NULL;
-static const char *cmdname = NULL;
+static char *cmdname = NULL;
 static char *execname = NULL;
-static char *startas = NULL;
 static const char *pidfile = NULL;
 static const char *progname = "";
 
@@ -122,9 +123,8 @@
     -x|--exec <executable>       program to start/check if it is running\n\
     -p|--pidfile <pid-file>      pid file to check\n\
     -u|--user <username>|<uid>   stop this user's processes\n\
-    -n|--name <process-name>     stop processes with this name\n\
+    -n|--name <process-name>     start/stop processes with this name\n\
     -s|--signal <signal>         signal to send (default 15)\n\
-    -a|--startas <pathname>      program to start (default <executable>)\n\
     -t|--test                    test mode, don't do anything\n\
     -o|--oknodo                  exit status 0 (not 1) if nothing done\n\
     -q|--quiet  |  -v, --verbose\n\
@@ -183,9 +183,7 @@
 		case 'V':  /* --version */
 			printf("start-stop-daemon " VERSION "\n");
 			exit(0);
-		case 'a':  /* --startas <pathname> */
-			startas = optarg;
-			break;
+		case 'a':  /* --startas <pathname>: OBSOLETE */
 		case 'n':  /* --name <process-name> */
 			cmdname = optarg;
 			break;
@@ -225,11 +223,11 @@
 	if (!execname && !pidfile && !userspec)
 		badusage("need at least one of --exec, --pidfile or --user");
 
-	if (!startas)
-		startas = execname;
+	if (!cmdname)
+		cmdname = execname;
 
-	if (start && !startas)
-		badusage("--start needs --exec or --startas");
+	if (start && !cmdname)
+		badusage("--start needs --exec or --cmdname");
 }
 
 
@@ -262,25 +260,18 @@
 static int
 pid_is_cmd(int pid, const char *name)
 {
-	char buf[32];
-	FILE *f;
-	int c;
+	char buf[1024];
+	int h, c;
 
-	sprintf(buf, "/proc/%d/stat", pid);
-	f = fopen(buf, "r");
-	if (!f)
-		return 0;
-	while ((c = getc(f)) != EOF && c != '(')
-		;
-	if (c != '(') {
-		fclose(f);
+	sprintf(buf, "/proc/%d/cmdline", pid);
+	if ( (h=open(buf, O_RDONLY)) < 0 ||
+	     (c=read( h, buf, 1023)) <= 0 ) {
 		return 0;
 	}
-	/* this hopefully handles command names containing ')' */
-	while ((c = getc(f)) != EOF && c == *name)
-		name++;
-	fclose(f);
-	return (c == ')' && *name == '\0');
+	close( h);
+	buf[ c] = '\0';
+
+	return ( !strcmp( name, buf) );
 }
 
 
@@ -354,7 +345,7 @@
 		fatal("internal error, please report");
 
 	if (!found) {
-		if (quietmode <= 0)
+		if (quietmode < 0)
 			printf("no %s found; none killed.\n", what);
 		exit(exitnodo);
 	}
@@ -373,6 +364,9 @@
 		for (p = killed; p; p = p->next)
 			printf(" %d", p->pid);
 		printf(").\n");
+	} else if (quietmode == 0) {
+		printf(" %s", what);
+		fflush( stdout);
 	}
 }
 
@@ -410,21 +404,25 @@
 	}
 
 	if (found) {
-		if (quietmode <= 0)
+		if (quietmode < 0)
 			printf("%s already running.\n", execname);
 		exit(exitnodo);
 	}
 	if (testmode) {
-		printf("would start %s ", startas);
+		printf("would start %s ", cmdname);
 		while (argc-- > 0)
 			printf("%s ", *argv++);
 		printf(".\n");
 		exit(0);
 	}
-	if (quietmode < 0)
-		printf("starting %s ...\n", startas);
-	*--argv = startas;
-	execv(startas, argv);
-	fatal("unable to start %s: %s", startas, strerror(errno));
+	if (quietmode < 0) {
+		printf("starting %s ...\n", cmdname);
+	} else if (quietmode == 0) {
+		printf(" %s", cmdname);
+		fflush( stdout);
+	}
+	*--argv = cmdname;
+	execv(execname, argv);
+	fatal("%s: %s", execname, strerror(errno));
 }
 
openSUSE Build Service is sponsored by