OSDN Git Service

* pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Make sure that process
authorcgf <cgf>
Sat, 22 Jan 2005 18:07:09 +0000 (18:07 +0000)
committercgf <cgf>
Sat, 22 Jan 2005 18:07:09 +0000 (18:07 +0000)
has exited before getting an error code.
(pinfo::exit): "cd" to innocuous location before exiting to make sure that
process does not keep the current working directory busy while it is in the
process of really exiting.

winsup/cygwin/ChangeLog
winsup/cygwin/pinfo.cc

index bf93bf7..f3a04b6 100644 (file)
@@ -1,3 +1,11 @@
+2005-01-22  Christopher Faylor  <cgf@timesys.com>
+
+       * pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Make sure that
+       process has exited before getting an error code.
+       (pinfo::exit): "cd" to innocuous location before exiting to make sure
+       that process does not keep the current working directory busy while it
+       is in the process of really exiting.
+
 2005-01-18  Corinna Vinschen  <corinna@vinschen.de>
 
        * autoload.cc (CoInitialize): Remove.
index 436785d..2771b2e 100644 (file)
@@ -111,6 +111,9 @@ pinfo::maybe_set_exit_code_from_windows ()
   DWORD oexitcode = self->exitcode;
   if (hProcess && !(self->exitcode & EXITCODE_SET))
     {
+      WaitForSingleObject (hProcess, INFINITE);        // just to be safe, in case
+                                               // process hasn't quite exited
+                                               // after closing pipe
       GetExitCodeProcess (hProcess, &x);
       self->exitcode = EXITCODE_SET | (x & 0xff) << 8;
     }
@@ -137,7 +140,10 @@ pinfo::exit (DWORD n)
 
   maybe_set_exit_code_from_windows ();
   if (n != EXITCODE_NOSET)
-    self->alert_parent (0);
+    {
+      SetCurrentDirectory ("c:\\");
+      self->alert_parent (0);
+    }
   int exitcode = self->exitcode;
   release ();