Changed various fopens to open read/write to avoid trashing files
authorCraig Leres <leres@ucbvax.Berkeley.EDU>
Wed, 25 May 1983 07:30:16 +0000 (23:30 -0800)
committerCraig Leres <leres@ucbvax.Berkeley.EDU>
Wed, 25 May 1983 07:30:16 +0000 (23:30 -0800)
when the file system gets full, etc.

SCCS-vsn: usr.bin/mail/quit.c 2.5

usr/src/usr.bin/mail/quit.c

index 4006bf4..10bd717 100644 (file)
@@ -9,7 +9,7 @@
  * Termination processing.
  */
 
  * Termination processing.
  */
 
-static char *SccsId = "@(#)quit.c      2.4 %G%";
+static char *SccsId = "@(#)quit.c      2.5 %G%";
 
 /*
  * Save all of the undetermined messages at the top of "mbox"
 
 /*
  * Save all of the undetermined messages at the top of "mbox"
@@ -177,7 +177,7 @@ quit()
                }
                fclose(obuf);
                close(creat(mbox, 0600));
                }
                fclose(obuf);
                close(creat(mbox, 0600));
-               if ((obuf = fopen(mbox, "w")) == NULL) {
+               if ((obuf = fopen(mbox, "r+")) == NULL) {
                        perror(mbox);
                        fclose(ibuf);
                        unlock();
                        perror(mbox);
                        fclose(ibuf);
                        unlock();
@@ -248,7 +248,7 @@ quit()
 
 cream:
        if (rbuf != NULL) {
 
 cream:
        if (rbuf != NULL) {
-               fbuf = fopen(mailname, "w");
+               fbuf = fopen(mailname, "r+");
                if (fbuf == NULL)
                        goto newmail;
                while ((c = getc(rbuf)) != EOF)
                if (fbuf == NULL)
                        goto newmail;
                while ((c = getc(rbuf)) != EOF)
@@ -282,7 +282,7 @@ writeback(res)
        FILE *obuf;
 
        p = 0;
        FILE *obuf;
 
        p = 0;
-       if ((obuf = fopen(mailname, "w")) == NULL) {
+       if ((obuf = fopen(mailname, "r+")) == NULL) {
                perror(mailname);
                return(-1);
        }
                perror(mailname);
                return(-1);
        }