]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC r243731,r255303: libc: Allow setting close-on-exec in fopen/freopen/
authorjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sun, 27 Oct 2013 21:49:52 +0000 (21:49 +0000)
committerjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sun, 27 Oct 2013 21:49:52 +0000 (21:49 +0000)
commit5415a5383c9a87da99b693dbf5c5bd91b821eb60
tree88349566da89c049ab02d8bcf778431cb6078973
parentef4938ed85a256243b21bad91e762de642b36967
MFC r243731,r255303: libc: Allow setting close-on-exec in fopen/freopen/
fdopen.

This commit adds a new mode option 'e'.

For freopen() with a non-NULL path argument and fopen(), the close-on-exec
flag is set iff the 'e' mode option is specified. For freopen() with a NULL
path argument and fdopen(), the close-on-exec flag is turned on if the 'e'
mode option is specified and remains unchanged otherwise.

Although the same behaviour for fopen() can be obtained by open(O_CLOEXEC)
and fdopen(), this needlessly complicates the calling code.

PR: kern/169320

git-svn-id: svn://svn.freebsd.org/base/stable/9@257229 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libc/stdio/fdopen.c
lib/libc/stdio/flags.c
lib/libc/stdio/fopen.3
lib/libc/stdio/freopen.c
tools/regression/lib/libc/stdio/test-fopen.c [new file with mode: 0644]
tools/regression/lib/libc/stdio/test-fopen.t [new file with mode: 0644]