]> sourceware.org Git - newlib-cygwin.git/commit
cwdstuff: Don't leave from setting the CWD prematurely on init
authorCorinna Vinschen <corinna@vinschen.de>
Fri, 3 Mar 2017 12:55:55 +0000 (13:55 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 3 Mar 2017 12:55:55 +0000 (13:55 +0100)
commit88443b0a2258993a20fb5d1d886860646e5202cc
tree6297f9d56cbd184b900ccc65baa2b2f885a71027
parent226f69422a44bbd177da6d8f3e1771f3b786fb0c
cwdstuff: Don't leave from setting the CWD prematurely on init

There are certain, very obscure scenarios, which render the Windows
CWD handle inaccessible for reopening.  An easy one is, the handle can
be NULL if the permissions of the CWD changed under the parent processes
feet.

Originally we just set errno and returned, but in case of init at
process startup that left the "posix" member NULL and subsequent
calls to getcwd failed with EFAULT.

We now check for a NULL handle and change the reopen approach
accordingly.  If that doesn't work, try to duplicate the handle instead.
If duplicating fails, too, we set the dir handle to NULL and carry on.
This will at least set posix to some valid path and subsequent getcwd
calls won't fail.  A NULL dir handle is ok, because we already do this
for virtual paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/path.cc
This page took 0.0325260000000001 seconds and 5 git commands to generate.