mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-15 21:49:22 +08:00
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>
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cygwin documentation is available on the net at https://cygwin.com You might especially be interested in https://cygwin.com/faq/faq.html#faq.programming.building-cygwin