slb

Sleep on Low Battery
Log | Files | Refs | README | LICENSE

commit 12cbef7085020673797d8d2ae11062c07a7d0fa5
parent 9a21794f162dfca1f2dae8492aa46ed4df6cbfea
Author: zerous Naveen Narayanan <zerous@nocebo.space>
Date:   Wed, 30 Oct 2019 21:29:26 +0100

Stop using redundant return value from daemoninit

Diffstat:
Mslb.c | 46++++++++++++++++++++++------------------------
1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/slb.c b/slb.c @@ -10,7 +10,7 @@ #include "config.h" -int +void daemoninit(void) { pid_t p; @@ -25,8 +25,6 @@ daemoninit(void) setsid(); chdir("/root"); umask(0); - - return 0; } int @@ -64,33 +62,33 @@ main(int argc, char **argv) pid_t p; openlog("slb", LOG_PID | LOG_CONS, LOG_DAEMON); - if (daemoninit()) - for (;;) { - tpow = 0; + daemoninit(); + for (;;) { + tpow = 0; - for (int i = 0; i < sizeof(bat)/sizeof(*bat); i++) { - tpow += pwread(bat[i]); - } + for (int i = 0; i < sizeof(bat)/sizeof(*bat); i++) { + tpow += pwread(bat[i]); + } - if (!pwread(ac) && (tpow < threshold)) { - if ((p = fork()) == -1) { - syslog(LOG_DAEMON|LOG_ERR, "fork error for %s: %m", "slb.c"); + if (!pwread(ac) && (tpow < threshold)) { + if ((p = fork()) == -1) { + syslog(LOG_DAEMON|LOG_ERR, "fork error for %s: %m", "slb.c"); + exit(1); + } + else if (p > 0) { + wait(NULL); + } + else if (p == 0) { + if ((t = execve(cmd, arg, NULL)) == -1) { + syslog(LOG_DAEMON|LOG_ERR, + "execve error for %s: %m", "slb.c"); exit(1); } - else if (p > 0) { - wait(NULL); - } - else if (p == 0) { - if ((t = execve(cmd,NULL,NULL)) == -1) { - syslog(LOG_DAEMON|LOG_ERR, - "execve error for %s: %m", "slb.c"); - exit(1); - } - } } - - sleep(delay); } + sleep(delay); + } + return 0; }