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 <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-08-24 18:37:53 +02:00
parent 986069c7e3
commit dbc1cae5c5
4 changed files with 37 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2015-08-24 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de>
* include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 2.

View file

@ -532,7 +532,8 @@ typedef enum _PROCESSINFOCLASS
ProcessTimes = 4,
ProcessSessionInformation = 24,
ProcessWow64Information = 26,
ProcessImageFileName = 27
ProcessImageFileName = 27,
ProcessDebugFlags = 31
} PROCESSINFOCLASS;
/* Checked on 64 bit. */

View file

@ -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

View file

@ -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);