summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-23 09:05:19 +0000
committerRoy Marples <roy@marples.name>2007-10-23 09:05:19 +0000
commitc30b64a63a2a4b22d1f51111e8fd2d82850d7985 (patch)
tree7639e11c3a4089926bfadc614ff7757f57dfc11a /src
parent2d7f57d462d90ff33e4e0a4e36290fc5f90fc9d6 (diff)
downloadopenrc-c30b64a63a2a4b22d1f51111e8fd2d82850d7985.tar.gz
openrc-c30b64a63a2a4b22d1f51111e8fd2d82850d7985.tar.bz2
openrc-c30b64a63a2a4b22d1f51111e8fd2d82850d7985.tar.xz
Allow half a second for a working pidfile to be created and a tenth of a second for a daemon to bail.
Diffstat (limited to 'src')
-rw-r--r--src/start-stop-daemon.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c
index 14bcdbb..98e0e53 100644
--- a/src/start-stop-daemon.c
+++ b/src/start-stop-daemon.c
@@ -13,7 +13,8 @@
/* nano seconds */
#define POLL_INTERVAL 20000000
-#define START_WAIT 500000000
+#define WAIT_PIDFILE 500000000
+#define START_WAIT 100000000
#define ONE_SECOND 1000000000
#include <sys/types.h>
@@ -974,8 +975,8 @@ int start_stop_daemon (int argc, char **argv)
if (START_WAIT > 0) {
struct timespec ts;
int nloops = START_WAIT / POLL_INTERVAL;
+ int nloopsp = WAIT_PIDFILE / POLL_INTERVAL;
bool alive = false;
- bool retestpid = false;
ts.tv_sec = 0;
ts.tv_nsec = POLL_INTERVAL;
@@ -989,7 +990,15 @@ int start_stop_daemon (int argc, char **argv)
return (0);
}
}
- nloops --;
+
+ /* We wait for a specific amount of time for a pidfile to be
+ * created. Once everything is in place we then wait some more
+ * to ensure that the daemon really is running and won't abort due
+ * to a config error. */
+ if (! background && pidfile && nloopsp)
+ nloopsp --;
+ else
+ nloops --;
/* This is knarly.
If we backgrounded then we know the exact pid.
@@ -1005,9 +1014,8 @@ int start_stop_daemon (int argc, char **argv)
/* The pidfile may not have been written yet - give it some time */
if (get_pid (pidfile, true) == -1) {
alive = true;
- retestpid = true;
} else {
- retestpid = false;
+ nloopsp = 0;
if (do_stop (NULL, NULL, pidfile, uid, 0,
true, false, true) > 0)
alive = true;
@@ -1022,12 +1030,6 @@ int start_stop_daemon (int argc, char **argv)
if (! alive)
eerrorx ("%s: %s died", applet, exec);
}
-
- if (retestpid) {
- if (do_stop (NULL, NULL, pidfile, uid, 0, true,
- false, true) < 1)
- eerrorx ("%s: %s died", applet, exec);
- }
}
if (svcname)