From 5ef0399ddd44e2f2e36d1a944f39e07544be8bbb Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 24 Apr 2017 17:34:31 +0200 Subject: [PATCH] cygwin: pinfo: do not wait for setting ppid on a transitional procinfo This leads to excessive lag when stracing processes if the inferior process checks the process table. The reason is that ppid isn't set in the procinfo memory of the dynamically loading strace itself. Signed-off-by: Corinna Vinschen --- winsup/cygwin/pinfo.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index e43082d4a..f5a659d86 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -314,12 +314,17 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) /* Detect situation where a transitional memory block is being retrieved. If the block has been allocated with PINFO_REDIR_SIZE but not yet updated with a PID_EXECED state then we'll retry. */ - if (!created && !(flag & PID_NEW)) - /* If not populated, wait 2 seconds for procinfo to become populated. - Would like to wait with finer granularity but that is not easily - doable. */ - for (int i = 0; i < 200 && !procinfo->ppid; i++) - Sleep (10); + if (!created && !(flag & PID_NEW) && !procinfo->ppid) + { + /* Fetching process info for /proc or ps? just ignore this one. */ + if (flag & PID_NOREDIR) + break; + /* If not populated, wait 2 seconds for procinfo to become populated. + Would like to wait with finer granularity but that is not easily + doable. */ + for (int i = 0; i < 200 && !procinfo->ppid; i++) + Sleep (10); + } if (!created && createit && (procinfo->process_state & PID_REAPED)) {