File at-3.1.13-massive_batch.patch of Package at

Index: atd.c
===================================================================
--- atd.c.orig
+++ atd.c
@@ -112,13 +112,14 @@ gid_t daemon_gid = (gid_t) - 3;
 
 static char *namep;
 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;
 
 #ifdef WITH_PAM
 #include <security/pam_appl.h>
@@ -146,14 +147,14 @@ set_term(int dummy)
 {
     term_signal = 1;
     return;
 }
 
-RETSIGTYPE 
-sdummy(int dummy)
+RETSIGTYPE
+set_hup(int dummy)
 {
-    /* Empty signal handler */
+    hupped = 1;
     nothing_to_do = 0;
     return;
 }
 
 /* SIGCHLD handler - discards completion status of children */
@@ -807,10 +808,11 @@ run_loop()
 
     if (nothing_to_do && buf.st_mtime <= last_chg)
 	return next_job;
     last_chg = buf.st_mtime;
 
+    hupped = 0;
     if ((spool = opendir(".")) == NULL)
 	perr("Cannot read " ATJOB_DIR);
 
     run_batch = 0;
     nothing_to_do = 1;
@@ -1043,11 +1045,11 @@ main(int argc, char *argv[])
      * A signal handler setting term_signal will make sure there's
      * a clean exit.
      */
 
     sigaction(SIGHUP, NULL, &act);
-    act.sa_handler = sdummy;
+    act.sa_handler = set_hup;
     sigaction(SIGHUP, &act, NULL);
 
     sigaction(SIGTERM, NULL, &act);
     act.sa_handler = set_term;
     sigaction(SIGTERM, &act, NULL);
@@ -1059,12 +1061,13 @@ main(int argc, char *argv[])
     daemon_setup();
 
     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);
 }
openSUSE Build Service is sponsored by