diff options
author | Rob Landley <rob@landley.net> | 2006-09-04 18:59:39 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-09-04 18:59:39 +0000 |
commit | 8cedabaee09937809802e1791cbc6caffdbd3024 (patch) | |
tree | 93b1b412b5fb93192767bf6a92eb05cc4b64fdac | |
parent | adff40e80d1dcfa6620b133512487b4dedda2422 (diff) | |
download | busybox-w32-8cedabaee09937809802e1791cbc6caffdbd3024.tar.gz busybox-w32-8cedabaee09937809802e1791cbc6caffdbd3024.tar.bz2 busybox-w32-8cedabaee09937809802e1791cbc6caffdbd3024.zip |
Patch from Natanael Copa to make start-stop-daemon just use readlink and
strcmp to check if a program is already running.
-rw-r--r-- | debianutils/start_stop_daemon.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 9c9b5fe77..e0c8f2d9b 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
@@ -39,16 +39,17 @@ static inline void push(pid_t pid) | |||
39 | 39 | ||
40 | static int pid_is_exec(pid_t pid, const char *name) | 40 | static int pid_is_exec(pid_t pid, const char *name) |
41 | { | 41 | { |
42 | char buf[32]; | 42 | char buf[32], *execbuf; |
43 | struct stat sb, exec_stat; | 43 | int equal; |
44 | |||
45 | if (name) | ||
46 | xstat(name, &exec_stat); | ||
47 | 44 | ||
48 | sprintf(buf, "/proc/%d/exe", pid); | 45 | sprintf(buf, "/proc/%d/exe", pid); |
49 | if (stat(buf, &sb) != 0) | 46 | execbuf = xstrdup(name); |
50 | return 0; | 47 | readlink(buf, execbuf, strlen(name)+1); |
51 | return (sb.st_dev == exec_stat.st_dev && sb.st_ino == exec_stat.st_ino); | 48 | |
49 | equal = ! strcmp(execbuf, name); | ||
50 | if (ENABLE_FEATURE_CLEAN_UP) | ||
51 | free(execbuf); | ||
52 | return equal; | ||
52 | } | 53 | } |
53 | 54 | ||
54 | static int pid_is_user(int pid, int uid) | 55 | static int pid_is_user(int pid, int uid) |