From e9da9dfb94b580edb617562c7681b9646fbc7255 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 18 Dec 2013 04:28:46 +0000 Subject: [PATCH] * autoload.cc (timeBeginPeriod): Autoload. * dcrt0.cc (dll_crt0_1): Use timeBeginPeriod to set default resolution to 1 ms. * pinfo.cc (pinfo::thisproc): Set ppid for redirected _pinfo blocks too. (pinfo::init): Avoid using VirtualQuery. Just rely on the assumption that procinfo will be populated. * pinfo.h (_pinfo::ppid): Move into redirected block. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/autoload.cc | 1 + winsup/cygwin/dcrt0.cc | 1 + winsup/cygwin/pinfo.cc | 12 ++++-------- winsup/cygwin/pinfo.h | 5 ++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8c973f901..19b7a5e68 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2013-12-17 Christopher Faylor + + * autoload.cc (timeBeginPeriod): Autoload. + * dcrt0.cc (dll_crt0_1): Use timeBeginPeriod to set default resolution + to 1 ms. + * pinfo.cc (pinfo::thisproc): Set ppid for redirected _pinfo blocks too. + (pinfo::init): Avoid using VirtualQuery. Just rely on the assumption that + procinfo will be populated. + * pinfo.h (_pinfo::ppid): Move into redirected block. + 2013-12-17 Christopher Faylor * external.cc (fillout_pinfo): Remove nonsensical loop. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 0199cc553..8a98b5b29 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -643,6 +643,7 @@ LoadDLLfunc (SetParent, 8, user32) LoadDLLfunc (SetProcessWindowStation, 4, user32) LoadDLLfunc (SetThreadDesktop, 4, user32) +LoadDLLfunc (timeBeginPeriod, 4, winmm) LoadDLLfuncEx3 (waveInAddBuffer, 12, winmm, 1, 0, 1) LoadDLLfuncEx3 (waveInClose, 4, winmm, 1, 0, 1) LoadDLLfuncEx3 (waveInGetNumDevs, 0, winmm, 1, 0, 1) diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index d348d9bd5..3d430a958 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -836,6 +836,7 @@ dll_crt0_1 (void *) { extern void initial_setlocale (); + timeBeginPeriod (1); _my_tls.incyg++; /* Inherit "parent" exec'ed process sigmask */ if (spawn_info && !in_forkee) diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 8f9986fc2..a22a9d7b3 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -77,6 +77,7 @@ pinfo::thisproc (HANDLE h) myself_identity.init (cygwin_pid (procinfo->dwProcessId), PID_EXECED, NULL); procinfo->exec_sendsig = NULL; procinfo->exec_dwProcessId = 0; + myself_identity->ppid = procinfo->pid; } } @@ -317,14 +318,9 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) 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)) - { - MEMORY_BASIC_INFORMATION mbi; - for (int i = 0; i < 1000 && !procinfo->ppid; i++) - Sleep (0); - if (procinfo->exists () && VirtualQuery (procinfo, &mbi, sizeof (mbi)) - && mbi.RegionSize < sizeof (_pinfo)) - goto loop; - } + /* If not populated, wait 2 seconds for procinfo to become populated */ + for (int i = 0; i < 2000 && !procinfo->ppid; i++) + Sleep (1); if (!created && createit && (procinfo->process_state & PID_REAPED)) { diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 0a13c4bf8..1d6a72cfa 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -50,6 +50,8 @@ public: constants in . */ DWORD process_state; + pid_t ppid; /* Parent process id. */ + DWORD exitcode; /* set when process exits */ #define PINFO_REDIR_SIZE ((char *) &myself.procinfo->exitcode - (char *) myself.procinfo) @@ -57,9 +59,6 @@ public: /* > 0 if started by a cygwin process */ DWORD cygstarted; - /* Parent process id. */ - pid_t ppid; - /* dwProcessId contains the processid used for sending signals. It will be reset in a child process when it is capable of receiving signals. */