try to handle out of disk space problem effectively
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 16 Oct 1980 02:19:45 +0000 (18:19 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 16 Oct 1980 02:19:45 +0000 (18:19 -0800)
SCCS-vsn: usr.sbin/sendmail/src/collect.c 1.4

usr/src/usr.sbin/sendmail/src/collect.c

index e6f52c5..18c633e 100644 (file)
@@ -1,5 +1,6 @@
 # include <stdio.h>
 # include <ctype.h>
 # include <stdio.h>
 # include <ctype.h>
+# include <errno.h>
 # include "dlvrmail.h"
 
 static char    SccsId[] = "@(#)collect.c       1.4     %G%";
 # include "dlvrmail.h"
 
 static char    SccsId[] = "@(#)collect.c       1.4     %G%";
@@ -50,6 +51,7 @@ maketemp()
        register bool inheader;
        bool firstline;
        char c;
        register bool inheader;
        bool firstline;
        char c;
+       extern int errno;
 
        /*
        **  Create the temp file name and create the file.
 
        /*
        **  Create the temp file name and create the file.
@@ -160,9 +162,15 @@ maketemp()
                firstline = FALSE;
                if (ferror(tf))
                {
                firstline = FALSE;
                if (ferror(tf))
                {
-                       syserr("Cannot write %s", InFileName);
-                       clearerr(tf);
-                       break;
+                       if (errno == ENOSPC)
+                       {
+                               freopen(InFileName, "w", tf);
+                               fputs("\nMAIL DELETED BECAUSE OF LACK OF DISK SPACE\n\n", tf);
+                               syserr("Out of disk space for temp file");
+                       }
+                       else
+                               syserr("Cannot write %s", InFileName);
+                       freopen("/dev/null", "w", tf);
                }
        }
        fclose(tf);
                }
        }
        fclose(tf);