fixed the reload utility

This commit is contained in:
SJ
2013-09-29 10:24:05 +02:00
parent e9cbc803ab
commit a1060b76d0
4 changed files with 15 additions and 7 deletions

View File

@ -25,7 +25,7 @@ struct __config cfg;
void fatal(char *s){
printf("pilerctl: fatal: %s\n", s);
syslog(LOG_PRIORITY, "fatal: %s", s);
exit(1);
}
@ -35,6 +35,8 @@ int main(int argc, char **argv){
int pid;
FILE *f;
(void) openlog("pilerreload", LOG_PID, LOG_MAIL);
cfg = read_config(CONFIG_FILE);
f = fopen(cfg.pidfile, "r");
@ -46,7 +48,11 @@ int main(int argc, char **argv){
pid = atoi(buf);
if(pid > 1) kill(pid, SIGHUP);
if(pid > 1){
if(kill(pid, SIGHUP) == 0) syslog(LOG_PRIORITY, "reloaded");
else syslog(LOG_PRIORITY, "failed to reload");
}
else fatal("invalid pid");
return 0;
}