Patch from Natanael Copa to make start-stop-daemon just use readlink and
authorRob Landley <rob@landley.net>
Mon, 4 Sep 2006 18:59:39 +0000 (18:59 -0000)
committerRob Landley <rob@landley.net>
Mon, 4 Sep 2006 18:59:39 +0000 (18:59 -0000)
strcmp to check if a program is already running.

debianutils/start_stop_daemon.c

index 9c9b5fe779845b71dd77e855d747833d66b86f13..e0c8f2d9b1d6c1a2b30ffecd8657401f260977d4 100644 (file)
@@ -39,16 +39,17 @@ static inline void push(pid_t pid)
 
 static int pid_is_exec(pid_t pid, const char *name)
 {
-       char buf[32];
-       struct stat sb, exec_stat;
-
-       if (name)
-               xstat(name, &exec_stat);
+       char buf[32], *execbuf;
+       int equal;
 
        sprintf(buf, "/proc/%d/exe", pid);
-       if (stat(buf, &sb) != 0)
-               return 0;
-       return (sb.st_dev == exec_stat.st_dev && sb.st_ino == exec_stat.st_ino);
+       execbuf = xstrdup(name);
+       readlink(buf, execbuf, strlen(name)+1);
+       
+       equal = ! strcmp(execbuf, name);
+       if (ENABLE_FEATURE_CLEAN_UP)
+               free(execbuf);
+       return equal;
 }
 
 static int pid_is_user(int pid, int uid)