int pid;
smallint state;
smallint ctrl;
- smallint want;
+ smallint sd_want;
smallint islog;
struct timespec start;
int fdlock;
if (s->ctrl & C_PAUSE) p = add_str(p, ", paused");
if (s->ctrl & C_TERM) p = add_str(p, ", got TERM");
if (s->state != S_DOWN)
- switch (s->want) {
+ switch (s->sd_want) {
case W_DOWN:
p = add_str(p, ", want down");
break;
status.pid_le32 = SWAP_LE32(s->pid);
if (s->ctrl & C_PAUSE)
status.paused = 1;
- if (s->want == W_UP)
+ if (s->sd_want == W_UP)
status.want = 'u';
else
status.want = 'd';
s->ctrl |= C_TERM;
update_status(s);
}
- if (s->want == W_DOWN) {
+ if (s->sd_want == W_DOWN) {
kill(s->pid, SIGCONT);
custom(s, 'd');
return;
}
- if (s->want == W_EXIT) {
+ if (s->sd_want == W_EXIT) {
kill(s->pid, SIGCONT);
custom(s, 'x');
}
switch (c) {
case 'd': /* down */
- s->want = W_DOWN;
+ s->sd_want = W_DOWN;
update_status(s);
if (s->pid && s->state != S_FINISH)
stopservice(s);
break;
case 'u': /* up */
- s->want = W_UP;
+ s->sd_want = W_UP;
update_status(s);
if (s->pid == 0)
startservice(s);
case 'x': /* exit */
if (s->islog)
break;
- s->want = W_EXIT;
+ s->sd_want = W_EXIT;
update_status(s);
/* FALLTHROUGH */
case 't': /* sig term */
update_status(s);
break;
case 'o': /* once */
- s->want = W_DOWN;
+ s->sd_want = W_DOWN;
update_status(s);
if (!s->pid)
startservice(s);
/* bss: svd[0].pid = 0; */
if (S_DOWN) svd[0].state = S_DOWN; /* otherwise already 0 (bss) */
if (C_NOOP) svd[0].ctrl = C_NOOP;
- if (W_UP) svd[0].want = W_UP;
+ if (W_UP) svd[0].sd_want = W_UP;
/* bss: svd[0].islog = 0; */
/* bss: svd[1].pid = 0; */
gettimeofday_ns(&svd[0].start);
- if (stat("down", &s) != -1) svd[0].want = W_DOWN;
+ if (stat("down", &s) != -1)
+ svd[0].sd_want = W_DOWN;
if (stat("log", &s) == -1) {
if (errno != ENOENT)
haslog = 1;
svd[1].state = S_DOWN;
svd[1].ctrl = C_NOOP;
- svd[1].want = W_UP;
+ svd[1].sd_want = W_UP;
svd[1].islog = 1;
gettimeofday_ns(&svd[1].start);
if (stat("log/down", &s) != -1)
- svd[1].want = W_DOWN;
+ svd[1].sd_want = W_DOWN;
xpiped_pair(logpipe);
close_on_exec_on(logpipe.rd);
close_on_exec_on(logpipe.wr);
char ch;
if (haslog)
- if (!svd[1].pid && svd[1].want == W_UP)
+ if (!svd[1].pid && svd[1].sd_want == W_UP)
startservice(&svd[1]);
if (!svd[0].pid)
- if (svd[0].want == W_UP || svd[0].state == S_FINISH)
+ if (svd[0].sd_want == W_UP || svd[0].state == S_FINISH)
startservice(&svd[0]);
x[0].fd = selfpipe.rd;
sigterm = 0;
}
- if (svd[0].want == W_EXIT && svd[0].state == S_DOWN) {
+ if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) {
if (svd[1].pid == 0)
_exit(EXIT_SUCCESS);
- if (svd[1].want != W_EXIT) {
- svd[1].want = W_EXIT;
+ if (svd[1].sd_want != W_EXIT) {
+ svd[1].sd_want = W_EXIT;
/* stopservice(&svd[1]); */
update_status(&svd[1]);
close(logpipe.wr);