Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-06-04 05:26:05 +0400
committerChristopher Faylor <me@cgf.cx>2012-06-04 05:26:05 +0400
commitb9c61a8d7b5b9bc43b3605c93fdee85c6dd04f13 (patch)
treee0bdbe1960fa0b274f8d0cc3ad582121af32af86 /winsup/cygwin/dtable.cc
parent3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r--winsup/cygwin/dtable.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 059d782d0..0ca64da2e 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -714,6 +714,14 @@ dtable::dup3 (int oldfd, int newfd, int flags)
debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags);
lock ();
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))
{
@@ -761,11 +769,11 @@ dtable::dup3 (int oldfd, int newfd, int flags)
goto done;
}
- do_unlock = false;
fds[newfd] = newfh;
if ((res = newfd) <= 2)
set_std_handle (res);
+ do_unlock = unlock_on_return;
done:
MALLOC_CHECK;