On Sun, Mar 4, 2012 at 2:35 PM, Ed W <[email protected]> wrote:
> Hi, I see a difference in behaviour between "real" start-stop-daemon on
> gentoo and busybox version.  Specifically nginx renames it's parent process
> commandline name:
>
> # cat /proc/`cat /var/run/nginx.pid`/cmdline
> nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
>
> However, I can stop it without a problem on "real" start-stop-daemon
> # start-stop-daemon --stop --exec /usr/sbin/nginx --pidfile
> /var/run/nginx.pid
>
> However, using busybox start-stop-daemon I get an error
>
> $ start-stop-daemon --stop --exec /usr/sbin/nginx --pidfile
> /var/run/nginx.pid
> no /usr/sbin/nginx found; none killed

Please try attached patch.

-- 
vda
diff -d -urpN busybox.8/debianutils/start_stop_daemon.c busybox.9/debianutils/start_stop_daemon.c
--- busybox.8/debianutils/start_stop_daemon.c	2011-11-09 19:35:08.000000000 +0100
+++ busybox.9/debianutils/start_stop_daemon.c	2012-03-05 16:20:04.435904950 +0100
@@ -198,8 +198,18 @@ static int pid_is_exec(pid_t pid)
 {
 	ssize_t bytes;
 	char buf[sizeof("/proc/%u/cmdline") + sizeof(int)*3];
+	char *procname, *exelink;
+	int match;
 
-	sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
+	procname = buf + sprintf(buf, "/proc/%u/exe", (unsigned)pid) - 3;
+
+	exelink = xmalloc_readlink(buf);
+	match = (exelink && strcmp(execname, exelink) == 0);
+	free(exelink);
+	if (match)
+		return match;
+
+	strcpy(procname, "cmdline");
 	bytes = open_read_close(buf, G.execname_cmpbuf, G.execname_sizeof);
 	if (bytes > 0) {
 		G.execname_cmpbuf[bytes] = '\0';
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to