[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] proposal for fix bug 770 (start-stop-daemon)
From:       Natanael Copa <natanael.copa () gmail ! com>
Date:       2006-08-29 10:03:51
Message-ID: 1156845831.32627.14.camel () localhost
[Download RAW message or body]

The attatched patch should fix bug 770 wihtout increasing the size.

Tested on x86_64.


["start-stop-daemon-bug770.patch" (start-stop-daemon-bug770.patch)]

Index: start_stop_daemon.c
===================================================================
--- start_stop_daemon.c	(revision 16010)
+++ start_stop_daemon.c	(working copy)
@@ -37,18 +37,20 @@
 	found = p;
 }
 
-static int pid_is_exec(pid_t pid, const char *name)
+static int pid_is_cmdline(pid_t pid, const char *name)
 {
 	char buf[32];
-	struct stat sb, exec_stat;
+	FILE *f;
+	int c;
 
-	if (name)
-		xstat(name, &exec_stat);
-
-	sprintf(buf, "/proc/%d/exe", pid);
-	if (stat(buf, &sb) != 0)
+	sprintf(buf, "/proc/%d/cmdline", pid);
+	f = fopen(buf, "r");
+	if (!f)
 		return 0;
-	return (sb.st_dev == exec_stat.st_dev && sb.st_ino == exec_stat.st_ino);
+	while ((c = getc(f)) != EOF && c == *name && *name != '\0')
+		name++;
+	fclose(f);
+	return (*name == '\0');
 }
 
 static int pid_is_user(int pid, int uid)
@@ -88,7 +90,7 @@
 
 static void check(int pid)
 {
-	if (execname && !pid_is_exec(pid, execname)) {
+	if (execname && !pid_is_cmdline(pid, execname)) {
 		return;
 	}
 	if (userspec && !pid_is_user(pid, user_id)) {


_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic