Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-06-11 21:57:10 +0400
committerChristopher Faylor <me@cgf.cx>2001-06-11 21:57:10 +0400
commit3ecfcf5715a1a998e9b976e09a7e6a0e8adc7aed (patch)
treea713d9ca64bf5f6425f793edb63ea41f941a7bd3 /winsup/cygwin
parenta179327987c7825123089c13779638b987c5fb49 (diff)
* pinfo.cc: Use autoloaded ToolHelp functions throughout for Win9x.
* autoload.cc: Autoload ToolHelp functions.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/autoload.cc3
-rw-r--r--winsup/cygwin/pinfo.cc32
-rw-r--r--winsup/cygwin/sigproc.cc27
4 files changed, 31 insertions, 36 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c977ed038..b8736f369 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 11 13:55:04 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * pinfo.cc: Use autoloaded ToolHelp functions throughout for Win9x.
+ * autoload.cc: Autoload ToolHelp functions.
+
Mon Jun 11 11:18:56 2001 Christopher Faylor <cgf@cygnus.com>
* path.cc (chdir): Fix call to path_conv constructor so that it REALLY
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 9da788957..1cd0e7e12 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -475,6 +475,9 @@ LoadDLLfunc (CoCreateInstance, 20, ole32)
LoadDLLfuncEx (SignalObjectAndWait, 16, kernel32, 1)
LoadDLLfuncEx (CancelIo, 4, kernel32, 1)
+LoadDLLfuncEx (Process32First, 8, kernel32, 1)
+LoadDLLfuncEx (Process32Next, 8, kernel32, 1)
+LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
LoadDLLfuncEx (waveOutGetNumDevs, 0, winmm, 1)
LoadDLLfuncEx (waveOutOpen, 24, winmm, 1)
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index e19371299..996137a3c 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -282,14 +282,6 @@ cygwin_winpid_to_pid (int winpid)
#include <tlhelp32.h>
-typedef HANDLE (WINAPI * CREATESNAPSHOT) (DWORD, DWORD);
-typedef BOOL (WINAPI * PROCESSWALK) (HANDLE, LPPROCESSENTRY32);
-typedef BOOL (WINAPI * CLOSESNAPSHOT) (HANDLE);
-
-static NO_COPY CREATESNAPSHOT myCreateToolhelp32Snapshot = NULL;
-static NO_COPY PROCESSWALK myProcess32First = NULL;
-static NO_COPY PROCESSWALK myProcess32Next = NULL;
-
#define slop_pidlist 200
#define size_pidlist(i) (sizeof (pidlist[0]) * ((i) + 1))
#define size_pinfolist(i) (sizeof (pinfolist[0]) * ((i) + 1))
@@ -369,7 +361,7 @@ winpids::enum9x (bool winpid)
{
DWORD nelem = 0;
- HANDLE h = myCreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
+ HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
if (!h)
{
system_printf ("Couldn't create process snapshot, %E");
@@ -379,13 +371,13 @@ winpids::enum9x (bool winpid)
PROCESSENTRY32 proc;
proc.dwSize = sizeof (proc);
- if (myProcess32First (h, &proc))
+ if (Process32First (h, &proc))
do
{
if (proc.th32ProcessID)
add (nelem, winpid, proc.th32ProcessID);
}
- while (myProcess32Next (h, &proc));
+ while (Process32Next (h, &proc));
CloseHandle (h);
return nelem;
@@ -401,26 +393,10 @@ winpids::init (bool winpid)
DWORD
winpids::enum_init (bool winpid)
{
- HINSTANCE h;
if (os_being_run == winNT)
enum_processes = &winpids::enumNT;
else
- {
- h = GetModuleHandle ("kernel32.dll");
- myCreateToolhelp32Snapshot = (CREATESNAPSHOT)
- GetProcAddress(h, "CreateToolhelp32Snapshot");
- myProcess32First = (PROCESSWALK)
- GetProcAddress (h, "Process32First");
- myProcess32Next = (PROCESSWALK)
- GetProcAddress (h, "Process32Next");
- if (!myCreateToolhelp32Snapshot || !myProcess32First || !myProcess32Next)
- {
- system_printf ("Couldn't find toolhelp processes, %E");
- return 0;
- }
-
- enum_processes = &winpids::enum9x;
- }
+ enum_processes = &winpids::enum9x;
return (this->*enum_processes) (winpid);
}
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 1e0c48762..64256508a 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -46,7 +46,7 @@ details. */
#define no_signals_available() (!hwait_sig || !sig_loop_wait)
-#define ZOMBIEMAX ((int) (sizeof (zombies) / sizeof (zombies[0])))
+#define ZOMBIEMAX ((int) (sizeof (zombies) / sizeof (zombies[0])) - 1)
/*
* Global variables
@@ -300,13 +300,12 @@ proc_subproc (DWORD what, DWORD val)
sigproc_printf ("pid %d[%d] terminated, handle %p, nchildren %d, nzombies %d",
pchildren[val]->pid, val, hchildren[val], nchildren, nzombies);
- if (nzombies >= ZOMBIEMAX)
- sigproc_printf ("Hit zombie maximum %d", nzombies);
- else
- {
- zombies[nzombies] = pchildren[val]; // Add to zombie array
- zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
- }
+
+ int thiszombie;
+ thiszombie = nzombies;
+ zombies[nzombies] = pchildren[val]; // Add to zombie array
+ zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
+
sigproc_printf ("removing [%d], pid %d, handle %p, nchildren %d",
val, pchildren[val]->pid, hchildren[val], nchildren);
if ((int) val < --nchildren)
@@ -314,6 +313,18 @@ proc_subproc (DWORD what, DWORD val)
hchildren[val] = hchildren[nchildren];
pchildren[val] = pchildren[nchildren];
}
+
+ /* See if we should care about the this terminated process. If we've
+ filled up our table or if we're ignoring SIGCHLD, then we immediately
+ remove the process and move on. Otherwise, this process becomes a zombie
+ which must be reaped by a wait() call. */
+ if (nzombies >= ZOMBIEMAX
+ || myself->getsig (SIGCHLD).sa_handler == (void *) SIG_IGN)
+ {
+ sigproc_printf ("automatically removing zombie %d", thiszombie);
+ remove_zombie (thiszombie);
+ }
+
/* Don't scan the wait queue yet. Caller will send SIGCHLD to this process.
This will cause an eventual scan of waiters. */
break;