Date: Sun, 26 Jun 2011 10:50:11 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r223565 - stable/8/lib/libc/gen Message-ID: <201106261050.p5QAoBDh049942@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Jun 26 10:50:11 2011 New Revision: 223565 URL: http://svn.freebsd.org/changeset/base/223565 Log: MFC r222511,r223206: posix_spawn(): Do not fail when trying to close an fd that is not open. As noted in Austin Group issue #370 (an interpretation has been issued), failing posix_spawn() because an fd specified with posix_spawn_file_actions_addclose() is not open is unnecessarily harsh, and there are existing implementations that do not fail posix_spawn() for this reason. Modified: stable/8/lib/libc/gen/posix_spawn.3 stable/8/lib/libc/gen/posix_spawn.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/gen/posix_spawn.3 ============================================================================== --- stable/8/lib/libc/gen/posix_spawn.3 Sun Jun 26 10:34:01 2011 (r223564) +++ stable/8/lib/libc/gen/posix_spawn.3 Sun Jun 26 10:50:11 2011 (r223565) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Mar 24, 2008 +.Dd June 17, 2011 .Dt POSIX_SPAWN 3 .Os .Sh NAME @@ -384,29 +384,28 @@ the child process exits with exit status .It If the .Fa file_actions -argument is not NULL, and specifies any close, dup2, or open actions to be +argument is not NULL, and specifies any dup2 or open actions to be performed, and if .Fn posix_spawn or .Fn posix_spawnp fails for any of the reasons that would cause -.Fn close , -.Fn dup2 , +.Fn dup2 or .Fn open to fail, an error value is returned as described by -.Fn close , -.Fn dup2 , +.Fn dup2 and .Fn open , respectively (or, if the error occurs after the calling process successfully returns, the child process exits with exit status 127). An open file action may, by itself, result in any of the errors described by -.Fn close -or .Fn dup2 , in addition to those described by .Fn open . +This implementation ignores any errors from +.Fn close , +including trying to close a descriptor that is not open. .El .Sh SEE ALSO .Xr close 2 , @@ -443,7 +442,13 @@ The and .Fn posix_spawnp functions conform to -.St -p1003.1-2001 . +.St -p1003.1-2001 , +except that they ignore all errors from +.Fn close . +A future update of the Standard is expected to require that these functions +not fail because a file descriptor to be closed (via +.Fn posix_spawn_file_actions_addclose ) +is not open. .Sh HISTORY The .Fn posix_spawn Modified: stable/8/lib/libc/gen/posix_spawn.c ============================================================================== --- stable/8/lib/libc/gen/posix_spawn.c Sun Jun 26 10:34:01 2011 (r223564) +++ stable/8/lib/libc/gen/posix_spawn.c Sun Jun 26 10:50:11 2011 (r223565) @@ -163,11 +163,8 @@ process_file_actions_entry(posix_spawn_f return (errno); break; case FAE_CLOSE: - /* Perform a close() */ - if (_close(fae->fae_fildes) != 0) { - if (errno == EBADF) - return (EBADF); - } + /* Perform a close(), do not fail if already closed */ + (void)_close(fae->fae_fildes); break; } return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106261050.p5QAoBDh049942>