]> granicus.if.org Git - strace/commitdiff
set CLOEXEC flag for outputfile
authorWichert Akkerman <wichert@deephackmode.org>
Fri, 3 Aug 2001 11:43:35 +0000 (11:43 +0000)
committerWichert Akkerman <wichert@deephackmode.org>
Fri, 3 Aug 2001 11:43:35 +0000 (11:43 +0000)
ChangeLog
strace.c

index dfd18dca783374e29c005b07e5faa9f49398c0b9..25ebed660482e8f9456fa3c2de56f6708b2f1b3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-08-03   Wichert Akkerman <wakkerma@debian.org>
+
+  * strace.c: set CLOEXEC  flag for outputfile
+
 2001-08-03   Wichert Akkerman <wakkerma@debian.org>
 
   * linux/sparc/syscall.h, linux/sparc/syscallent.h: add some LFS calls
index 083e850c3cdd9a219b66c3ca400340ab391c1162..dd3e935651cc9759c6ccedf228e187cfbe69e802 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -314,11 +314,23 @@ char *argv[];
 
        /* Check if they want to redirect the output. */
        if (outfname) {
+               long f;
+
                if ((outf = fopen(outfname, "w")) == NULL) {
                        fprintf(stderr, "%s: can't fopen '%s': %s\n",
                                progname, outfname, strerror(errno));
                        exit(1);
                }
+
+               if ((f=fcntl(fileno(outf), F_GETFD)) < 0 ) {
+                       perror("failed to get flags for outputfile");
+                       exit(1);
+               }
+
+               if (fcntl(fileno(outf), F_SETFD, f|FD_CLOEXEC) < 0 ) {
+                       perror("failed to set flags for outputfile");
+                       exit(1);
+               }
        }
 
 #ifndef SVR4