https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=dbc1cae5c50e358fa820fd3bff41e0990943054f
commit dbc1cae5c50e358fa820fd3bff41e0990943054f Author: Corinna Vinschen <[email protected]> Date: Mon Aug 24 18:37:53 2015 +0200 Fix hang stracing forking processes but not following child * ntdll.h (PROCESSINFOCLASS): Define ProcessDebugFlags. * sigproc.cc (child_info::child_info): Only propagate _CI_STRACED to child if strace is actually tracing child processes. Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/ntdll.h | 3 ++- winsup/cygwin/release/2.2.2 | 14 ++++++++++++++ winsup/cygwin/sigproc.cc | 16 +++++++++++++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e6b2223..1ec6c71 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2015-08-24 Corinna Vinschen <[email protected]> + * ntdll.h (PROCESSINFOCLASS): Define ProcessDebugFlags. + * sigproc.cc (child_info::child_info): Only propagate _CI_STRACED to + child if strace is actually tracing child processes. + +2015-08-24 Corinna Vinschen <[email protected]> + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 2. 2015-08-18 Corinna Vinschen <[email protected]> diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index 8088e40..13a131d 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -532,7 +532,8 @@ typedef enum _PROCESSINFOCLASS ProcessTimes = 4, ProcessSessionInformation = 24, ProcessWow64Information = 26, - ProcessImageFileName = 27 + ProcessImageFileName = 27, + ProcessDebugFlags = 31 } PROCESSINFOCLASS; /* Checked on 64 bit. */ diff --git a/winsup/cygwin/release/2.2.2 b/winsup/cygwin/release/2.2.2 new file mode 100644 index 0000000..eb2162b --- /dev/null +++ b/winsup/cygwin/release/2.2.2 @@ -0,0 +1,14 @@ +What's new: +----------- + + +What changed: +------------- + + +Bug Fixes +--------- + +- Fix a hang when stracing a forking or spawning process without activating + stracing of child processes. + Addresses: https://cygwin.com/ml/cygwin/2015-08/msg00390.html diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 12f61d2..1339250 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -772,7 +772,21 @@ child_info::child_info (unsigned in_cb, child_info_types chtype, fhandler_union_cb = sizeof (fhandler_union); user_h = cygwin_user_h; if (strace.active ()) - flag |= _CI_STRACED; + { + NTSTATUS status; + ULONG DebugFlags; + + /* Only propagate _CI_STRACED to child if strace is actually tracing + child processes of this process. The undocumented ProcessDebugFlags + returns 0 if EPROCESS->NoDebugInherit is TRUE, 1 otherwise. + This avoids a hang when stracing a forking or spawning process + with the -f flag set to "don't follow fork". */ + status = NtQueryInformationProcess (GetCurrentProcess (), + ProcessDebugFlags, &DebugFlags, + sizeof (DebugFlags), NULL); + if (NT_SUCCESS (status) && DebugFlags) + flag |= _CI_STRACED; + } if (need_subproc_ready) { subproc_ready = CreateEvent (&sec_all, FALSE, FALSE, NULL);
