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