summaryrefslogtreecommitdiff
path: root/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-08 03:48:52 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-08 03:48:52 +0200
commitb8c597d5d21e83966bdee8a701e6d994aaf650ee (patch)
tree9f075ec555264306faf58fefc031aed8ef602b43 /service.c
parent70123e68a04016efca9266fc22dd05a0a7fd2d51 (diff)
service: verify PID is valid when reading it from PID file
Diffstat (limited to 'service.c')
-rw-r--r--service.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/service.c b/service.c
index 3d840cbd92..832c7b3263 100644
--- a/service.c
+++ b/service.c
@@ -839,7 +839,13 @@ static int service_load_pid_file(Service *s) {
if ((unsigned long) (pid_t) p != p)
return -ERANGE;
- s->main_pid = p;
+ if (kill((pid_t) p, 0) < 0 && errno != EPERM) {
+ log_warning("PID %llu read from file %s does not exist. Your service or init script might be broken.",
+ (unsigned long long) p, s->pid_file);
+ return -ESRCH;
+ }
+
+ s->main_pid = (pid_t) p;
s->main_pid_known = true;
return 0;