diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e6b222322..1ec6c714b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-08-24 Corinna Vinschen + + * 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 * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 2. diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index 8088e40a2..13a131deb 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 000000000..eb2162b1e --- /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 12f61d2fb..13392504b 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);