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