mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
* dtable.cc (dtable::dup3): Only return with lock set when O_EXCL flag is
passed in. * syscalls.cc (dup_finish): Pass O_EXCL in flags to dtable::dup3.
This commit is contained in:
parent
3143cb7c00
commit
b9c61a8d7b
@ -1,3 +1,9 @@
|
|||||||
|
2012-06-03 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
|
* dtable.cc (dtable::dup3): Only return with lock set when O_EXCL flag
|
||||||
|
is passed in.
|
||||||
|
* syscalls.cc (dup_finish): Pass O_EXCL in flags to dtable::dup3.
|
||||||
|
|
||||||
2012-06-03 Christopher Faylor <me.cygwin2012@cgf.cx>
|
2012-06-03 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
* DevNotes: Add entry cgf-000011.
|
* DevNotes: Add entry cgf-000011.
|
||||||
|
@ -714,6 +714,14 @@ dtable::dup3 (int oldfd, int newfd, int flags)
|
|||||||
debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags);
|
debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags);
|
||||||
lock ();
|
lock ();
|
||||||
bool do_unlock = true;
|
bool do_unlock = true;
|
||||||
|
bool unlock_on_return;
|
||||||
|
if (!(flags & O_EXCL))
|
||||||
|
unlock_on_return = true; /* Relinquish lock on return */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flags &= ~O_EXCL;
|
||||||
|
unlock_on_return = false; /* Return with lock set on success */
|
||||||
|
}
|
||||||
|
|
||||||
if (not_open (oldfd))
|
if (not_open (oldfd))
|
||||||
{
|
{
|
||||||
@ -761,11 +769,11 @@ dtable::dup3 (int oldfd, int newfd, int flags)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_unlock = false;
|
|
||||||
fds[newfd] = newfh;
|
fds[newfd] = newfh;
|
||||||
|
|
||||||
if ((res = newfd) <= 2)
|
if ((res = newfd) <= 2)
|
||||||
set_std_handle (res);
|
set_std_handle (res);
|
||||||
|
do_unlock = unlock_on_return;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
|
@ -130,7 +130,7 @@ inline int
|
|||||||
dup_finish (int oldfd, int newfd, int flags)
|
dup_finish (int oldfd, int newfd, int flags)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if ((res = cygheap->fdtab.dup3 (oldfd, newfd, flags)) == newfd)
|
if ((res = cygheap->fdtab.dup3 (oldfd, newfd, flags | O_EXCL)) == newfd)
|
||||||
{
|
{
|
||||||
cygheap_fdget (newfd)->inc_refcnt ();
|
cygheap_fdget (newfd)->inc_refcnt ();
|
||||||
cygheap->fdtab.unlock (); /* dup3 exits with lock set on success */
|
cygheap->fdtab.unlock (); /* dup3 exits with lock set on success */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user