Author: jh
Date: Mon Oct 11 13:31:09 2010
New Revision: 213690
URL: http://svn.freebsd.org/changeset/base/213690

Log:
  MFC r200752:
  
  Avoid sharing the file descriptor of the output file with traced
  processes by setting the FD_CLOEXEC flag for the output file.
  
  PR:           bin/140493

Modified:
  stable/7/usr.bin/truss/main.c
Directory Properties:
  stable/7/usr.bin/truss/   (props changed)

Modified: stable/7/usr.bin/truss/main.c
==============================================================================
--- stable/7/usr.bin/truss/main.c       Mon Oct 11 12:57:41 2010        
(r213689)
+++ stable/7/usr.bin/truss/main.c       Mon Oct 11 13:31:09 2010        
(r213690)
@@ -231,6 +231,12 @@ main(int ac, char **av)
                if ((trussinfo->outfile = fopen(fname, "w")) == NULL)
                        errx(1, "cannot open %s", fname);
        }
+       /*
+        * Set FD_CLOEXEC, so that the output file is not shared with
+        * the traced process.
+        */
+       if (fcntl(fileno(trussinfo->outfile), F_SETFD, FD_CLOEXEC) == -1)
+               warn("fcntl()");
 
        /*
         * If truss starts the process itself, it will ignore some signals --
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to