aboutsummaryrefslogtreecommitdiffstats
path: root/src/ppp-watch.c
diff options
context:
space:
mode:
authorMichael K. Johnson <johnsonm@redhat.com>1999-09-28 20:44:49 +0000
committerMichael K. Johnson <johnsonm@redhat.com>1999-09-28 20:44:49 +0000
commit46ef8a5eda67ef2fd99b75877802f0a244c6f141 (patch)
tree9a25440d5553edc6e9cbd717bbeb7af09e96f007 /src/ppp-watch.c
parentff3e62eeef1535888049e152d77d6d9d65f81894 (diff)
downloadinitscripts-46ef8a5eda67ef2fd99b75877802f0a244c6f141.tar
initscripts-46ef8a5eda67ef2fd99b75877802f0a244c6f141.tar.gz
initscripts-46ef8a5eda67ef2fd99b75877802f0a244c6f141.tar.bz2
initscripts-46ef8a5eda67ef2fd99b75877802f0a244c6f141.tar.xz
initscripts-46ef8a5eda67ef2fd99b75877802f0a244c6f141.zip
recover if dead daemon left pidfile
Diffstat (limited to 'src/ppp-watch.c')
-rw-r--r--src/ppp-watch.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ppp-watch.c b/src/ppp-watch.c
index 2580e0ec..44a6edd5 100644
--- a/src/ppp-watch.c
+++ b/src/ppp-watch.c
@@ -169,6 +169,7 @@ doPidFile(char *device) {
pidFileName = device;
pidFilePath = alloca(strlen(pidFileName) + 25);
sprintf(pidFilePath, "/var/run/pppwatch-%s.pid", pidFileName);
+restart:
fd = open(pidFilePath, O_WRONLY|O_TRUNC|O_CREAT|O_EXCL,
S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH);
@@ -184,10 +185,16 @@ doPidFile(char *device) {
*/
f = fdopen(fd, "r");
if (!f) cleanExit(37);
- if (fscanf(f, "%d", &pid) && pid)
- kill(pid, SIGHUP);
+ fscanf(f, "%d", &pid);
fclose(f);
- cleanExit(33);
+ if (pid) {
+ if (kill(pid, SIGHUP)) {
+ unlink(pidFilePath);
+ goto restart;
+ } else {
+ cleanExit(33);
+ }
+ }
}
f = fdopen(fd, "w");