diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2019-02-05 12:52:13 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2019-02-05 12:52:13 +0100 |
commit | 7225a82c1a4e90bcea2a17da12a427d1e783de30 (patch) | |
tree | 9951249eefa8b627566b6582ecfa0851782a8c1c | |
parent | fb3e8bd88b06be6b5e748b99aa50968bb46653a1 (diff) | |
download | cygnal-7225a82c1a4e90bcea2a17da12a427d1e783de30.tar.gz cygnal-7225a82c1a4e90bcea2a17da12a427d1e783de30.tar.bz2 cygnal-7225a82c1a4e90bcea2a17da12a427d1e783de30.zip |
Cygwin: fork: terminate child process unconditionally in error case
Move TerminateProcess call into cleanup code to make sure child
doesn't linger in some border cases.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fork.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 6f0036433..5f775249a 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -400,7 +400,6 @@ frok::parent (volatile char * volatile stack_here) we can't actually record the pid in the internal table. */ if (!child.remember (false)) { - TerminateProcess (hchild, 1); this_errno = EAGAIN; #ifdef DEBUGGING0 error ("child remember failed"); @@ -508,8 +507,12 @@ cleanup: __malloc_unlock (); /* Remember to de-allocate the fd table. */ - if (hchild && !child.hProcess) /* no child.procinfo */ - ForceCloseHandle1 (hchild, childhProc); + if (hchild) + { + TerminateProcess (hchild, 1); + if (!child.hProcess) /* no child.procinfo */ + ForceCloseHandle1 (hchild, childhProc); + } if (forker_finished) ForceCloseHandle (forker_finished); debug_printf ("returning -1"); |