diff options
author | Guillem Jover <guillem@debian.org> | 2008-08-03 22:01:38 +0300 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2008-08-04 07:09:35 +0300 |
commit | b5c0381ff4d7508368a897ed375f9ae509fef56b (patch) | |
tree | 79e99f82cc2c210093ac8a8ca244016d24548901 /utils | |
parent | 4ab792e665280c1a535045ee29f2a877304fb514 (diff) | |
download | dpkg-b5c0381ff4d7508368a897ed375f9ae509fef56b.tar.gz |
s-s-d: Use kill instead of /proc to check for pid existence
Diffstat (limited to 'utils')
-rw-r--r-- | utils/start-stop-daemon.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index cb37932bb..7890b08f4 100644 --- a/utils/start-stop-daemon.c +++ b/utils/start-stop-daemon.c @@ -904,17 +904,12 @@ pid_is_running(pid_t pid) static int pid_is_running(pid_t pid) { - struct stat sb; - char buf[32]; - - sprintf(buf, "/proc/%d", pid); - if (stat(buf, &sb) != 0) { - if (errno != ENOENT) - fatal("Error stating %s: %s", buf, strerror(errno)); + if (kill(pid, 0) == 0 || errno == EPERM) + return 1; + else if (errno == ESRCH) return 0; - } - - return 1; + else + fatal("Error checking pid %u status: %s", pid, strerror(errno)); } #endif |