From 4c133af135710baebf958820a48cc096605a4a5c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 22 Jan 2005 18:07:10 +0000 Subject: [PATCH] * 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. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/pinfo.cc | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bf93bf70a..f3a04b676 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2005-01-22 Christopher Faylor + + * 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 * autoload.cc (CoInitialize): Remove. diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 436785da8..2771b2ed2 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -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 ();