* pinfo.cc (EnumProcessesNT): Avoid 0 pids.
(EnumProcesses9x): Ditto. * sigproc.cc (remove_childe): Eliminate. (proc_subproc): Move remove_child stuff here. (wait_subproc): Synchronize with proc_subproc when error occurs. Add more debugging info. * sigproc.h (procstuff): Add an entry. * spawn.cc (spawn_guts): Add sigframe here.
This commit is contained in:
parent
46209564d4
commit
e46db834d9
|
@ -1,3 +1,14 @@
|
||||||
|
Sat Nov 4 00:51:38 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* pinfo.cc (EnumProcessesNT): Avoid 0 pids.
|
||||||
|
(EnumProcesses9x): Ditto.
|
||||||
|
* sigproc.cc (remove_childe): Eliminate.
|
||||||
|
(proc_subproc): Move remove_child stuff here.
|
||||||
|
(wait_subproc): Synchronize with proc_subproc when error occurs. Add
|
||||||
|
more debugging info.
|
||||||
|
* sigproc.h (procstuff): Add an entry.
|
||||||
|
* spawn.cc (spawn_guts): Add sigframe here.
|
||||||
|
|
||||||
Fri Nov 3 20:07:14 2000 Christopher Faylor <cgf@cygnus.com>
|
Fri Nov 3 20:07:14 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* sigproc.cc (wait_subproc): Refine debug output.
|
* sigproc.cc (wait_subproc): Refine debug output.
|
||||||
|
|
|
@ -327,14 +327,17 @@ EnumProcessesNT (DWORD* &pidlist, DWORD &npidlist)
|
||||||
SYSTEM_PROCESSES *px = procs;
|
SYSTEM_PROCESSES *px = procs;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (nelem >= npidlist)
|
if (px->ProcessId)
|
||||||
{
|
{
|
||||||
npidlist += slop_pidlist;
|
if (nelem >= npidlist)
|
||||||
pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist));
|
{
|
||||||
|
npidlist += slop_pidlist;
|
||||||
|
pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist));
|
||||||
|
}
|
||||||
|
pidlist[nelem++] = cygwin_pid (px->ProcessId);
|
||||||
|
if (!px->NextEntryDelta)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
pidlist[nelem++] = cygwin_pid (px->ProcessId);
|
|
||||||
if (!px->NextEntryDelta)
|
|
||||||
break;
|
|
||||||
px = (SYSTEM_PROCESSES *) ((char *) px + px->NextEntryDelta);
|
px = (SYSTEM_PROCESSES *) ((char *) px + px->NextEntryDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +362,8 @@ EnumProcesses9x (DWORD* &pidlist, DWORD &npidlist)
|
||||||
if (myProcess32First(h, &proc))
|
if (myProcess32First(h, &proc))
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (!proc.th32ProcessID)
|
||||||
|
continue;
|
||||||
if (nelem >= npidlist)
|
if (nelem >= npidlist)
|
||||||
{
|
{
|
||||||
npidlist += slop_pidlist;
|
npidlist += slop_pidlist;
|
||||||
|
|
|
@ -116,7 +116,6 @@ int NO_COPY pending_signals = 0; // TRUE if signals pending
|
||||||
static int __stdcall checkstate (waitq *);
|
static int __stdcall checkstate (waitq *);
|
||||||
static __inline__ BOOL get_proc_lock (DWORD, DWORD);
|
static __inline__ BOOL get_proc_lock (DWORD, DWORD);
|
||||||
static HANDLE __stdcall getsem (_pinfo *, const char *, int, int);
|
static HANDLE __stdcall getsem (_pinfo *, const char *, int, int);
|
||||||
static void __stdcall remove_child (int);
|
|
||||||
static void __stdcall remove_zombie (int);
|
static void __stdcall remove_zombie (int);
|
||||||
static DWORD WINAPI wait_sig (VOID *arg);
|
static DWORD WINAPI wait_sig (VOID *arg);
|
||||||
static int __stdcall stopped_or_terminated (waitq *, _pinfo *);
|
static int __stdcall stopped_or_terminated (waitq *, _pinfo *);
|
||||||
|
@ -285,7 +284,13 @@ proc_subproc (DWORD what, DWORD val)
|
||||||
pchildren[val]->pid, val, hchildren[val], nchildren, nzombies);
|
pchildren[val]->pid, val, hchildren[val], nchildren, nzombies);
|
||||||
zombies[nzombies] = pchildren[val]; // Add to zombie array
|
zombies[nzombies] = pchildren[val]; // Add to zombie array
|
||||||
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
|
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
|
||||||
remove_child (val); // Remove from children array
|
sigproc_printf ("removing [%d], pid %d, handle %p, nchildren %d",
|
||||||
|
val, pchildren[val]->pid, hchildren[val], nchildren);
|
||||||
|
if ((int) val < --nchildren)
|
||||||
|
{
|
||||||
|
hchildren[val] = hchildren[nchildren];
|
||||||
|
pchildren[val] = pchildren[nchildren];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* A child is in the stopped state. Scan wait() queue to see if anyone
|
/* A child is in the stopped state. Scan wait() queue to see if anyone
|
||||||
|
@ -934,23 +939,6 @@ get_proc_lock (DWORD what, DWORD val)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a child from pchildren/hchildren by swapping it with the
|
|
||||||
* last child in the list.
|
|
||||||
*/
|
|
||||||
static void __stdcall
|
|
||||||
remove_child (int ci)
|
|
||||||
{
|
|
||||||
sigproc_printf ("removing [%d], pid %d, handle %p, nchildren %d",
|
|
||||||
ci, pchildren[ci]->pid, hchildren[ci], nchildren);
|
|
||||||
if (ci < --nchildren)
|
|
||||||
{
|
|
||||||
pchildren[ci] = pchildren[nchildren];
|
|
||||||
hchildren[ci] = hchildren[nchildren];
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
||||||
*/
|
*/
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
|
@ -1250,7 +1238,9 @@ wait_subproc (VOID *)
|
||||||
closed a handle in the children[] array. So, we try looping a couple
|
closed a handle in the children[] array. So, we try looping a couple
|
||||||
of times to stabilize. FIXME - this is not foolproof. Probably, this
|
of times to stabilize. FIXME - this is not foolproof. Probably, this
|
||||||
thread should be responsible for closing the children. */
|
thread should be responsible for closing the children. */
|
||||||
if (++errloop < 10)
|
if (!errloop++)
|
||||||
|
proc_subproc (PROC_NOTHING, 0); // Just synchronize and continue
|
||||||
|
if (errloop < 10)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
system_printf ("wait failed. nchildren %d, wait %d, %E",
|
system_printf ("wait failed. nchildren %d, wait %d, %E",
|
||||||
|
@ -1262,9 +1252,10 @@ wait_subproc (VOID *)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
system_printf ("event[%d] %p, pchildren[%d] %p, %E", i, i, pchildren[i]);
|
system_printf ("nchildren %d, event[%d] %p, pchildren[%d] %p, %E",
|
||||||
system_printf ("pid %d, dwProcessId %u, progname '%s'", i,
|
nchildren, i, events[0], i, (_pinfo *) pchildren[i]);
|
||||||
events[0], pchildren[i]->pid, pchildren[i]->dwProcessId,
|
system_printf ("pid %d, dwProcessId %u, progname '%s'",
|
||||||
|
pchildren[i]->pid, pchildren[i]->dwProcessId,
|
||||||
pchildren[i]->progname);
|
pchildren[i]->progname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,7 +20,8 @@ enum procstuff
|
||||||
PROC_CHILDSTOPPED = 2, // a child stopped
|
PROC_CHILDSTOPPED = 2, // a child stopped
|
||||||
PROC_CHILDTERMINATED = 3, // a child died
|
PROC_CHILDTERMINATED = 3, // a child died
|
||||||
PROC_CLEARWAIT = 4, // clear all waits - signal arrived
|
PROC_CLEARWAIT = 4, // clear all waits - signal arrived
|
||||||
PROC_WAIT = 5 // setup for wait() for subproc
|
PROC_WAIT = 5, // setup for wait() for subproc
|
||||||
|
PROC_NOTHING = 6 // nothing, really
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct struct_waitq
|
typedef struct struct_waitq
|
||||||
|
|
|
@ -289,6 +289,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
||||||
{
|
{
|
||||||
BOOL rc;
|
BOOL rc;
|
||||||
pid_t cygpid;
|
pid_t cygpid;
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue