selinux/*: -Wunused-parameter fixes
runsv: make it NOMMU-capable
function old new delta
startservice 291 313 +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 22/0) Total: 22 bytes
diff --git a/runit/runsv.c b/runit/runsv.c
index 0da03e6..2ab034a 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -256,15 +256,16 @@
if (s->islog) return 0;
strcpy(a, "control/?");
- a[8] = c;
+ a[8] = c; /* replace '?' */
if (stat(a, &st) == 0) {
if (st.st_mode & S_IXUSR) {
- pid = fork();
+ pid = vfork();
if (pid == -1) {
- warn_cannot("fork for control/?");
+ warn_cannot("vfork for control/?");
return 0;
}
if (!pid) {
+ /* child */
if (haslog && dup2(logpipe.wr, 1) == -1)
warn_cannot("setup stdout for control/?");
prog[0] = a;
@@ -272,6 +273,7 @@
execv(a, prog);
fatal_cannot("run control/?");
}
+ /* parent */
while (safe_waitpid(pid, &w, 0) == -1) {
warn_cannot("wait for child control/?");
return 0;
@@ -318,8 +320,8 @@
if (s->pid != 0)
stopservice(s); /* should never happen */
- while ((p = fork()) == -1) {
- warn_cannot("fork, sleeping");
+ while ((p = vfork()) == -1) {
+ warn_cannot("vfork, sleeping");
sleep(5);
}
if (p == 0) {
@@ -344,6 +346,7 @@
execvp(*run, run);
fatal2_cannot(s->islog ? "start log/" : "start ", *run);
}
+ /* parent */
if (s->state != S_FINISH) {
gettimeofday_ns(&s->start);
s->state = S_RUN;