aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/pinfo.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-01-22 18:07:10 +0000
committerChristopher Faylor <me@cgf.cx>2005-01-22 18:07:10 +0000
commit4c133af135710baebf958820a48cc096605a4a5c (patch)
tree91ed303d2e075fa9a36a9e1d86b853b79f87069a /winsup/cygwin/pinfo.cc
parentf2d6aeea176db3a9121ee345e03d410a22ac7a1d (diff)
downloadnewlib-4c133af135710baebf958820a48cc096605a4a5c.zip
newlib-4c133af135710baebf958820a48cc096605a4a5c.tar.gz
newlib-4c133af135710baebf958820a48cc096605a4a5c.tar.bz2
* 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.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 436785d..2771b2e 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 ();