This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] cygwin: pinfo: do not wait for setting ppid on a transitional procinfo


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5ef0399ddd44e2f2e36d1a944f39e07544be8bbb

commit 5ef0399ddd44e2f2e36d1a944f39e07544be8bbb
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Apr 24 17:34:31 2017 +0200

    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 <corinna@vinschen.de>

Diff:
---
 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 e43082d..f5a659d 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))
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]