2013-06-11 13:42:01 +00:00
|
|
|
Index: atd.c
|
|
|
|
===================================================================
|
2010-09-28 20:34:15 +00:00
|
|
|
--- atd.c.orig
|
2009-01-08 13:50:40 +00:00
|
|
|
+++ atd.c
|
2017-07-27 14:14:04 +00:00
|
|
|
@@ -108,9 +108,10 @@ static char *namep;
|
2008-04-08 20:15:40 +00:00
|
|
|
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;
|
|
|
|
|
2017-07-27 14:14:04 +00:00
|
|
|
@@ -141,10 +142,10 @@ set_term(int dummy)
|
2013-06-11 13:42:01 +00:00
|
|
|
return;
|
2008-04-08 20:15:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-11 13:42:01 +00:00
|
|
|
-RETSIGTYPE
|
2008-04-08 20:15:40 +00:00
|
|
|
-sdummy(int dummy)
|
2013-06-11 13:42:01 +00:00
|
|
|
+RETSIGTYPE
|
2008-04-08 20:15:40 +00:00
|
|
|
+set_hup(int dummy)
|
|
|
|
{
|
|
|
|
- /* Empty signal handler */
|
|
|
|
+ hupped = 1;
|
2013-06-11 13:42:01 +00:00
|
|
|
nothing_to_do = 0;
|
2008-04-08 20:15:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-07-27 14:14:04 +00:00
|
|
|
@@ -647,6 +648,7 @@ run_loop()
|
2008-04-08 20:15:40 +00:00
|
|
|
return next_job;
|
|
|
|
last_chg = buf.st_mtime;
|
|
|
|
|
|
|
|
+ hupped = 0;
|
|
|
|
if ((spool = opendir(".")) == NULL)
|
|
|
|
perr("Cannot read " ATJOB_DIR);
|
|
|
|
|
2017-07-27 14:14:04 +00:00
|
|
|
@@ -898,7 +900,7 @@ main(int argc, char *argv[])
|
2008-04-08 20:15:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
sigaction(SIGHUP, NULL, &act);
|
|
|
|
- act.sa_handler = sdummy;
|
|
|
|
+ act.sa_handler = set_hup;
|
|
|
|
sigaction(SIGHUP, &act, NULL);
|
|
|
|
|
|
|
|
sigaction(SIGTERM, NULL, &act);
|
2017-07-27 14:14:04 +00:00
|
|
|
@@ -914,9 +916,10 @@ main(int argc, char *argv[])
|
2008-04-08 20:15:40 +00:00
|
|
|
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);
|