summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2008-08-03 22:01:38 +0300
committerGuillem Jover <guillem@debian.org>2008-08-04 07:09:35 +0300
commitb5c0381ff4d7508368a897ed375f9ae509fef56b (patch)
tree79e99f82cc2c210093ac8a8ca244016d24548901 /utils
parent4ab792e665280c1a535045ee29f2a877304fb514 (diff)
downloaddpkg-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.c15
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