public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fork: terminate child process unconditionally in error case
@ 2019-02-05 11:55 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-02-05 11:55 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7225a82c1a4e90bcea2a17da12a427d1e783de30

commit 7225a82c1a4e90bcea2a17da12a427d1e783de30
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Feb 5 12:52:13 2019 +0100

    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>

Diff:
---
 winsup/cygwin/fork.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 6f00364..5f77524 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");


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-05 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05 11:55 [newlib-cygwin] Cygwin: fork: terminate child process unconditionally in error case Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).