snapshot 20050114 race (on list)

Christopher Faylor
Sat Jan 22 21:28:00 GMT 2005

On Sat, Jan 22, 2005 at 04:25:28PM -0500, Christopher Faylor wrote:
>On Mon, Jan 17, 2005 at 10:25:51PM -0500, Pierre A. Humblet wrote:
>>At 10:15 PM 1/17/2005 -0500, you wrote:
>>>On Mon, Jan 17, 2005 at 09:30:11PM -0500, Pierre A. Humblet wrote:
>>>>It's not a Cygwin handle.  It's an internal Windows handle to the
>>>>current working directory.  Ah! Doing a chdir to C:\ just before
>>>>alerting would fix this, except in the case of being terminated.
>>>If the process is terminated wouldn't this be a non-issue?
>>It depends on the timing between the pipe being closed by Windows
>>and the cwd handle being closed. This won't keep me awake.
>I put the SetCurrentDirectory suggestion into the latest cygwin but it
>just occurred to me that this needs to be called unconditionally since
>an execed child could exit prior to the stub exiting so, something like:
>  int bar;
>  mkdir ("/foo", 0777);
>  chdir ("/foo");
>  if (!fork ())
>    exec ("/bin/pwd");
>  wait (&bar);
>  chdir ("/");
>  rmdir ("/foo");
>wouldn't be guaranteed to work since there could be a stub that was
>still cd'ed to "/foo" even after "/bin/pwd" has finished executing.

Oh *@#$%!

Keeping the SetCurrentDirectory in exit won't work.  It has to happen
prior to the exec or there's still a race.


More information about the Cygwin-developers mailing list