d83c6e
diff -up at-3.1.20/at.c.shell at-3.1.20/at.c
d83c6e
--- at-3.1.20/at.c.shell	2016-07-01 09:47:13.392684445 +0200
d83c6e
+++ at-3.1.20/at.c	2016-07-01 09:48:47.679931959 +0200
d83c6e
@@ -62,11 +62,8 @@
d83c6e
 #include <stdlib.h>
d83c6e
 #include <string.h>
d83c6e
 
d83c6e
-#ifdef TM_IN_SYS_TIME
d83c6e
 #include <sys/time.h>
d83c6e
-#else
d83c6e
 #include <time.h>
d83c6e
-#endif
d83c6e
 
d83c6e
 #ifdef HAVE_UNISTD_H
d83c6e
 #include <unistd.h>
d83c6e
@@ -239,6 +236,12 @@ writefile(time_t runtimer, char queue)
d83c6e
     int kill_errno;
d83c6e
     int rc;
d83c6e
     int mailsize = 128;
d83c6e
+    struct timeval tv;
d83c6e
+    struct timezone tz;
d83c6e
+    long int i;
d83c6e
+
d83c6e
+    gettimeofday(&tv, &tz;;
d83c6e
+    srandom(getpid()+tv.tv_usec);
d83c6e
 
d83c6e
 /* Install the signal handler for SIGINT; terminate after removing the
d83c6e
  * spool file if necessary
d83c6e
@@ -465,6 +468,9 @@ writefile(time_t runtimer, char queue)
d83c6e
     fprintf(fp, " || {\n\t echo 'Execution directory "
d83c6e
 	    "inaccessible' >&2\n\t exit 1\n}\n");
d83c6e
 
d83c6e
+    i = random();
d83c6e
+    fprintf(fp, "${SHELL:-/bin/sh} << \'marcinDELIMITER%08lx\'\n", i);
d83c6e
+
d83c6e
     istty = isatty(fileno(stdin));
d83c6e
     if (istty) {
d83c6e
 	fprintf(stderr, "at> ");
d83c6e
@@ -480,7 +486,7 @@ writefile(time_t runtimer, char queue)
d83c6e
     if (istty) {
d83c6e
 	fprintf(stderr, "<EOT>\n");
d83c6e
     }
d83c6e
-    fprintf(fp, "\n");
d83c6e
+    fprintf(fp, "\nmarcinDELIMITER%08lx\n", i);
d83c6e
     if (ferror(fp))
d83c6e
 	panic("Output error");
d83c6e
     fflush(fp);