aboutsummaryrefslogtreecommitdiff
path: root/src/rc/runscript.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-18 00:09:03 +0000
committerRoy Marples <roy@marples.name>2009-04-18 00:09:03 +0000
commitc9e24a0494dc499728e5131d15a8a16d3fd97c5d (patch)
treecdc7677c88a18556968feb34aa368e445146e9f2 /src/rc/runscript.c
parentd4c71415a9514c3d478e6ed110cba72a0d80a378 (diff)
Move status to runscript.sh so init scripts can override it, #159
Return 32 if crashed, #163
Diffstat (limited to 'src/rc/runscript.c')
-rw-r--r--src/rc/runscript.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 8475633b..1fd9e9ab 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -352,11 +352,10 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
return ret;
}
-static bool
+static int
svc_exec(const char *arg1, const char *arg2)
{
- bool execok;
- int fdout = fileno(stdout);
+ int ret, fdout = fileno(stdout);
struct termios tt;
struct winsize ws;
int i;
@@ -467,13 +466,13 @@ svc_exec(const char *arg1, const char *arg2)
master_tty = -1;
}
- execok = rc_waitpid(service_pid) == 0 ? true : false;
- if (!execok && errno == ECHILD)
+ ret = WEXITSTATUS(rc_waitpid(service_pid));
+ if (ret != 0 && errno == ECHILD)
/* killall5 -9 could cause this */
- execok = true;
+ ret = 0;
service_pid = 0;
- return execok;
+ return ret;
}
static bool
@@ -788,7 +787,7 @@ svc_start(bool deps)
setenv("IN_BACKGROUND", ibsave, 1);
hook_out = RC_HOOK_SERVICE_START_DONE;
rc_plugin_run(RC_HOOK_SERVICE_START_NOW, applet);
- started = svc_exec("start", NULL);
+ started = (svc_exec("start", NULL) == 0);
if (ibsave)
unsetenv("IN_BACKGROUND");
@@ -961,7 +960,7 @@ svc_stop(bool deps)
setenv("IN_BACKGROUND", ibsave, 1);
hook_out = RC_HOOK_SERVICE_STOP_DONE;
rc_plugin_run(RC_HOOK_SERVICE_STOP_NOW, applet);
- stopped = svc_exec("stop", NULL);
+ stopped = (svc_exec("stop", NULL) == 0);
if (ibsave)
unsetenv("IN_BACKGROUND");
@@ -1286,10 +1285,10 @@ runscript(int argc, char **argv)
rc_stringlist_free(services);
services = NULL;
} else if (strcmp (optarg, "status") == 0) {
- RC_SERVICE r = svc_status();
- retval = (int) r;
- if (retval & RC_SERVICE_STARTED)
- retval = 0;
+ save = prefix;
+ eprefix(NULL);
+ prefix = NULL;
+ retval = svc_exec("status", NULL);
} else {
if (strcmp(optarg, "conditionalrestart") == 0 ||
strcmp(optarg, "condrestart") == 0)