- use FD_CLOEXEC instead of 1 - use O_CLOEXEC with open() instead of open/fcntl
Index: usr.bin/chpass/chpass.c =================================================================== RCS file: /cvs/src/usr.bin/chpass/chpass.c,v retrieving revision 1.38 diff -N -u -p usr.bin/chpass/chpass.c --- usr.bin/chpass/chpass.c 20 Jun 2012 21:32:27 -0000 1.38 +++ usr.bin/chpass/chpass.c 18 Jan 2013 05:27:30 -0000 @@ -168,7 +168,7 @@ main(int argc, char *argv[]) if ((pw = pw_dup(pw)) == NULL) pw_error(NULL, 1, 1); dfd = mkstemp(tempname); - if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1) + if (dfd == -1 || fcntl(dfd, F_SETFD, FD_CLOEXEC) == -1) pw_error(tempname, 1, 1); display(tempname, dfd, pw); edit_status = edit(tempname, pw); @@ -216,8 +216,8 @@ main(int argc, char *argv[]) } if (i >= 4) fputc('\n', stderr); - pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); - if (pfd == -1 || fcntl(pfd, F_SETFD, 1) == -1) + pfd = open(_PATH_MASTERPASSWD, O_RDONLY|O_CLOEXEC, 0); + if (pfd == -1) pw_error(_PATH_MASTERPASSWD, 1, 1); #ifdef YP