runsv: another tiny optimization
function old new delta startservice 297 288 -9 ctrl 435 426 -9
This commit is contained in:
parent
f09f4e015b
commit
31773b71e8
@ -304,15 +304,14 @@ static void stopservice(struct svdir *s)
|
|||||||
static void startservice(struct svdir *s)
|
static void startservice(struct svdir *s)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
char *run[2];
|
const char *run;
|
||||||
|
|
||||||
if (s->state == S_FINISH)
|
if (s->state == S_FINISH)
|
||||||
run[0] = (char*)"./finish";
|
run = "./finish";
|
||||||
else {
|
else {
|
||||||
run[0] = (char*)"./run";
|
run = "./run";
|
||||||
custom(s, 'u');
|
custom(s, 'u');
|
||||||
}
|
}
|
||||||
run[1] = NULL;
|
|
||||||
|
|
||||||
if (s->pid != 0)
|
if (s->pid != 0)
|
||||||
stopservice(s); /* should never happen */
|
stopservice(s); /* should never happen */
|
||||||
@ -340,8 +339,8 @@ static void startservice(struct svdir *s)
|
|||||||
, SIG_DFL);*/
|
, SIG_DFL);*/
|
||||||
sig_unblock(SIGCHLD);
|
sig_unblock(SIGCHLD);
|
||||||
sig_unblock(SIGTERM);
|
sig_unblock(SIGTERM);
|
||||||
execvp(*run, run);
|
execl(run, run, (char *) NULL);
|
||||||
fatal2_cannot(s->islog ? "start log/" : "start ", *run);
|
fatal2_cannot(s->islog ? "start log/" : "start ", run);
|
||||||
}
|
}
|
||||||
/* parent */
|
/* parent */
|
||||||
if (s->state != S_FINISH) {
|
if (s->state != S_FINISH) {
|
||||||
@ -395,8 +394,7 @@ static int ctrl(struct svdir *s, char c)
|
|||||||
case 'c': /* sig cont */
|
case 'c': /* sig cont */
|
||||||
if (s->pid && !custom(s, c))
|
if (s->pid && !custom(s, c))
|
||||||
kill(s->pid, SIGCONT);
|
kill(s->pid, SIGCONT);
|
||||||
if (s->ctrl & C_PAUSE)
|
s->ctrl &= ~C_PAUSE;
|
||||||
s->ctrl &= ~C_PAUSE;
|
|
||||||
update_status(s);
|
update_status(s);
|
||||||
break;
|
break;
|
||||||
case 'o': /* once */
|
case 'o': /* once */
|
||||||
|
Loading…
Reference in New Issue
Block a user