diff options
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.h | 7 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 9 |
3 files changed, 17 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ca1fc5314..1401a18fa 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2011-11-04 Christopher Faylor <me.cygwin2011@cgf.cx> + * pinfo.h (pinfo::reattach): Only set destroy to false when + proc_subproc succeeds. Return true for success. + * sigproc.cc (child_info_spawn::reattach_children): Try harder to clean + up on error by detecting reattach failures too. + +2011-11-04 Christopher Faylor <me.cygwin2011@cgf.cx> + * sigproc.cc (child_info_spawn::reattach_children): Clean up handle when can't open parent process or suffer handle leak. diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index f9e859cde..a69316148 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -175,10 +175,11 @@ public: #ifndef _SIGPROC_H int remember () {system_printf ("remember is not here"); return 0;} #else - void reattach () + int reattach () { - proc_subproc (PROC_REATTACH_CHILD, (DWORD) this); - destroy = false; + int res = proc_subproc (PROC_REATTACH_CHILD, (DWORD) this); + destroy = res ? false : true; + return res; } int remember (bool detach) { diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index a3035d9ca..be570c496 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -866,10 +866,13 @@ child_info_spawn::reattach_children () false, DUPLICATE_SAME_ACCESS)) debug_printf ("couldn't duplicate parent %p handles for forked children after exec, %E", children[i].rd_proc_pipe); - else if ((p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, p->pid))) - p.reattach (); - else + else if (!(p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, p->pid))) CloseHandle (p.rd_proc_pipe); + else if (!p.reattach ()) + { + CloseHandle (p.hProcess); + CloseHandle (p.rd_proc_pipe); + } } } |