aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-09-04 18:59:39 +0000
committerRob Landley <rob@landley.net>2006-09-04 18:59:39 +0000
commit8cedabaee09937809802e1791cbc6caffdbd3024 (patch)
tree93b1b412b5fb93192767bf6a92eb05cc4b64fdac /debianutils
parentadff40e80d1dcfa6620b133512487b4dedda2422 (diff)
downloadbusybox-8cedabaee09937809802e1791cbc6caffdbd3024.tar.gz
Patch from Natanael Copa to make start-stop-daemon just use readlink and
strcmp to check if a program is already running.
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c17
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)
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)