--- atd.c +++ atd.c @@ -140,9 +140,10 @@ static double load_avg = LOADAVG_MX; static time_t now; static time_t last_chg; -static int nothing_to_do; +static int nothing_to_do = 0; unsigned int batch_interval; static int run_as_daemon = 0; +static int hupped = 0; static volatile sig_atomic_t term_signal = 0; @@ -155,9 +156,10 @@ } RETSIGTYPE -sdummy(int dummy) +set_hup(int dummy) { - /* Empty signal handler */ + hupped = 1; + nothing_to_do = 0; return; } @@ -765,6 +767,7 @@ return next_job; last_chg = buf.st_mtime; + hupped = 0; if ((spool = opendir(".")) == NULL) perr("Cannot read " ATJOB_DIR); @@ -989,7 +992,7 @@ */ sigaction(SIGHUP, NULL, &act); - act.sa_handler = sdummy; + act.sa_handler = set_hup; sigaction(SIGHUP, &act, NULL); sigaction(SIGTERM, NULL, &act); @@ -1005,9 +1008,10 @@ do { now = time(NULL); next_invocation = run_loop(); - if (next_invocation > now) { + if ((next_invocation > now) && (!hupped)) { sleep(next_invocation - now); } + hupped = 0; } while (!term_signal); daemon_cleanup(); exit(EXIT_SUCCESS);