d3b522
diff -up at-3.1.16/at.c.fclose at-3.1.16/at.c
d3b522
--- at-3.1.16/at.c.fclose	2014-11-06 16:11:28.000000000 +0100
d3b522
+++ at-3.1.16/at.c	2014-11-24 15:30:12.704502966 +0100
d3b522
@@ -209,7 +209,11 @@ nextjob()
d3b522
     jobno = (1 + jobno) % 0xfffff;	/* 2^20 jobs enough? */
d3b522
     fprintf(fid, "%05lx\n", jobno);
d3b522
 
d3b522
-    fclose(fid);
d3b522
+    if (ferror(fid))
d3b522
+	jobno = EOF;
d3b522
+
d3b522
+    if (fclose(fid) != 0)
d3b522
+	jobno = EOF;
d3b522
     return jobno;
d3b522
 }
d3b522
 
d3b522
@@ -494,7 +498,8 @@ writefile(time_t runtimer, char queue)
d3b522
     if (ferror(stdin))
d3b522
 	panic("Input error");
d3b522
 
d3b522
-    fclose(fp);
d3b522
+    if (fclose(fp) != 0)
d3b522
+	panic("Output error");
d3b522
 
d3b522
     /* Set the x bit so that we're ready to start executing
d3b522
      */