don't truncate output files; bug report 4.2BSD/bin/43
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 8 Apr 1987 08:56:31 +0000 (00:56 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 8 Apr 1987 08:56:31 +0000 (00:56 -0800)
SCCS-vsn: bin/dd/dd.c 4.5

usr/src/bin/dd/dd.c

index e202d5f..6a1c11d 100644 (file)
@@ -2,6 +2,7 @@
 static char *sccsid = "@(#)dd.c        4.5 (Berkeley) %G%";
 #endif
 
 static char *sccsid = "@(#)dd.c        4.5 (Berkeley) %G%";
 #endif
 
+#include <sys/file.h>
 #include <stdio.h>
 #include <signal.h>
 
 #include <stdio.h>
 #include <signal.h>
 
@@ -257,10 +258,7 @@ char       **argv;
                perror(ifile);
                exit(1);
        }
                perror(ifile);
                exit(1);
        }
-       if (ofile)
-               obf = creat(ofile, 0666);
-       else
-               obf = dup(1);
+       obf = ofile ? open(ofile, O_WRONLY|O_CREAT, 0666) : dup(1);
        if(obf < 0) {
                fprintf(stderr,"cannot create: %s\n", ofile);
                exit(1);
        if(obf < 0) {
                fprintf(stderr,"cannot create: %s\n", ofile);
                exit(1);