ce9709
diff -up at-3.1.18/atd.c.nit at-3.1.18/atd.c
ce9709
--- at-3.1.18/atd.c.nit	2016-03-23 12:46:49.222277787 +0100
ce9709
+++ at-3.1.18/atd.c	2016-03-23 12:47:50.521639804 +0100
ce9709
@@ -196,6 +196,18 @@ myfork()
ce9709
 
ce9709
 #define fork myfork
ce9709
 #endif
ce9709
+#undef ATD_MAIL_PROGRAM
ce9709
+#undef ATD_MAIL_NAME
ce9709
+#if defined(SENDMAIL)
ce9709
+#define ATD_MAIL_PROGRAM SENDMAIL
ce9709
+#define ATD_MAIL_NAME    "sendmail"
ce9709
+#elif  defined(MAILC)
ce9709
+#define ATD_MAIL_PROGRAM MAILC
ce9709
+#define ATD_MAIL_NAME    "mail"
ce9709
+#elif  defined(MAILX)
ce9709
+#define ATD_MAIL_PROGRAM MAILX
ce9709
+#define ATD_MAIL_NAME    "mailx"
ce9709
+#endif
ce9709
 
ce9709
 #ifdef WITH_SELINUX
ce9709
 static int
ce9709
@@ -339,6 +351,9 @@ run_file(const char *filename, uid_t uid
ce9709
 	free(newname);
ce9709
 	return;
ce9709
     }
ce9709
+
ce9709
+    (void) setsid(); /* own session for process */
ce9709
+
ce9709
     /* Let's see who we mail to.  Hopefully, we can read it from
ce9709
      * the command file; if not, send it to the owner, or, failing that,
ce9709
      * to root.
ce9709
@@ -507,6 +522,9 @@ run_file(const char *filename, uid_t uid
ce9709
 	    if (setuid(uid) < 0)
ce9709
 		perr("Cannot set user id");
ce9709
 
ce9709
+	    if (SIG_ERR == signal(SIGCHLD, SIG_DFL))
ce9709
+		perr("Cannot reset signal handler to default");
ce9709
+
ce9709
 	    chdir("/");
ce9709
 
ce9709
 	    execle("/bin/sh", "sh", (char *) NULL, nenvp);
ce9709
@@ -572,6 +590,9 @@ run_file(const char *filename, uid_t uid
ce9709
 	    if (setuid(uid) < 0)
ce9709
 		perr("Cannot set user id");
ce9709
 
ce9709
+	    if (SIG_ERR == signal(SIGCHLD, SIG_DFL))
ce9709
+		perr("Cannot reset signal handler to default");
ce9709
+
ce9709
 	    chdir ("/");
ce9709
 
ce9709
 #if defined(SENDMAIL)
ce9709
@@ -699,6 +720,7 @@ run_loop()
ce9709
 		 * Let's remove the lockfile and reschedule.
ce9709
 		 */
ce9709
 		strncpy(lock_name, dirent->d_name, sizeof(lock_name));
ce9709
+		lock_name[sizeof(lock_name)-1] = '\0';
ce9709
 		lock_name[0] = '=';
ce9709
 		unlink(lock_name);
ce9709
 		next_job = now;
ce9709
@@ -733,6 +755,7 @@ run_loop()
ce9709
 	    run_batch++;
ce9709
 	    if (strcmp(batch_name, dirent->d_name) > 0) {
ce9709
 		strncpy(batch_name, dirent->d_name, sizeof(batch_name));
ce9709
+		batch_name[sizeof(batch_name)-1] = '\0';
ce9709
 		batch_uid = buf.st_uid;
ce9709
 		batch_gid = buf.st_gid;
ce9709
 		batch_queue = queue;
ce9709
diff -up at-3.1.18/at.1.in.nit at-3.1.18/at.1.in
ce9709
--- at-3.1.18/at.1.in.nit	2015-12-06 16:45:10.000000000 +0100
ce9709
+++ at-3.1.18/at.1.in	2016-03-23 12:46:49.226277876 +0100
ce9709
@@ -210,7 +210,7 @@ queue for
ce9709
 .BR batch .
ce9709
 Queues with higher letters run with increased niceness.  The special
ce9709
 queue "=" is reserved for jobs which are currently running.
ce9709
-.P
ce9709
+
ce9709
 If a job is submitted to a queue designated with an uppercase letter, the
ce9709
 job is treated as if it were submitted to batch at the time of the job.
ce9709
 Once the time is reached, the batch processing rules with respect to load