bin/152151: truss causes programs to open fd number 2,
clobbering random files
Ashish SHUKLA
ashish at FreeBSD.org
Fri Nov 12 00:00:30 UTC 2010
The following reply was made to PR bin/152151; it has been noted by GNATS.
From: ashish at FreeBSD.org (Ashish SHUKLA)
To: bug-followup at FreeBSD.org,brong at fastmail.fm
Cc:
Subject: Re: bin/152151: truss causes programs to open fd number 2, clobbering random files
Date: Fri, 12 Nov 2010 05:27:00 +0530
--=-=-=
Content-Type: text/plain
Hi,
Attached diff (based on the hints mentioned by Bron) fixes the problem for me.
HTH
--
Ashish SHUKLA | GPG: F682 CDCC 39DC 0FEA E116 20B6 C746 CFA9 E74F A4B0
freebsd.org!ashish | http://people.freebsd.org/~ashish/
Avoid Success At All Costs !!
--=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename=main.c.diff
Content-Description: diff
--- main.c~ 2010-11-11 23:46:13.000000000 +0000
+++ main.c 2010-11-11 23:55:11.000000000 +0000
@@ -238,13 +238,14 @@
if (fname != NULL) { /* Use output file */
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.
+ */
+ else if (fcntl(fileno(trussinfo->outfile), F_SETFD, FD_CLOEXEC) == -1)
+ warn("fcntl()");
}
- /*
- * 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 --
--=-=-=--
More information about the freebsd-bugs
mailing list