From c2b51d4457560eed58e28bcc230e42722aa01a4f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sun, 27 Jan 2013 03:17:35 +0000 Subject: truss: use 'e' flag for fopen instead of fcntl(.., FD_CLOEXEC) --- usr.bin/truss/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'usr.bin/truss') diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index 2b72c9560729..4e9f74b8a3cd 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -234,15 +234,12 @@ main(int ac, char **av) usage(); if (fname != NULL) { /* Use output file */ - if ((trussinfo->outfile = fopen(fname, "w")) == NULL) - err(1, "cannot open %s", fname); /* - * Set FD_CLOEXEC, so that the output file is not shared with - * the traced process. + * Set close-on-exec ('e'), 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 ((trussinfo->outfile = fopen(fname, "we")) == NULL) + err(1, "cannot open %s", fname); } /* -- cgit v1.2.3