* init.cc (dll_entry): Remove unused extern.

* include/sys/cygwin.h: Remove PID_ZOMBIE.
* pinfo.h: Rename EXITCODE_* defines.
(pinfo::set_exit_state): Remove parameter.
* pinfo.cc (set_exit_state): Remove parameter.  Reverse sense of test so that
exitcode is checked for having been set rather than not having been set.  Set
flag when exitcode has been established.  Don't set PID_STATE here.
(pinfo::init): Remove exitcode initialization.
(pinfo::exit): Reflect change in EXITCODE_* naming.  Set flag when exitcode has
been established.  Reflect change in arguments to set_process_state.
(proc_waiter): Reflect change in arguments to set_process_state.  Set
process_state here and only here.
* fhandler_process.cc (fhandler_process::fill_filebuf): Reflect removal of
PID_ZOMBIE define.
(format_process_stat): Ditto.
(format_process_status): Ditto.
* sigproc.cc (pid_exists): Ditto.
(stopped_or_terminated): Ditto.  Make sure that only low-order 16 bits of
exitcode are used.
* spawn.cc (spawn_guts): Reflect change in EXITCODE_* naming.
This commit is contained in:
Christopher Faylor 2005-01-16 17:00:27 +00:00
parent fdd857a1f6
commit 85b3fb9640
8 changed files with 51 additions and 31 deletions

View file

@ -1,3 +1,29 @@
2005-01-15 Christopher Faylor <cgf@timesys.com>
* init.cc (dll_entry): Remove unused extern.
* include/sys/cygwin.h: Remove PID_ZOMBIE.
* pinfo.h: Rename EXITCODE_* defines.
(pinfo::set_exit_state): Remove parameter.
* pinfo.cc (set_exit_state): Remove parameter. Reverse sense of test
so that exitcode is checked for having been set rather than not having
been set. Set flag when exitcode has been established. Don't set
PID_STATE here.
(pinfo::init): Remove exitcode initialization.
(pinfo::exit): Reflect change in EXITCODE_* naming. Set flag when
exitcode has been established. Reflect change in arguments to
set_process_state.
(proc_waiter): Reflect change in arguments to set_process_state. Set
process_state here and only here.
* fhandler_process.cc (fhandler_process::fill_filebuf): Reflect removal
of PID_ZOMBIE define.
(format_process_stat): Ditto.
(format_process_status): Ditto.
* sigproc.cc (pid_exists): Ditto.
(stopped_or_terminated): Ditto. Make sure that only low-order 16 bits of
exitcode are used.
* spawn.cc (spawn_guts): Reflect change in EXITCODE_* naming.
2005-01-15 Christopher Faylor <cgf@timesys.com>
* sigproc.cc (sig_send): Don't complain if attempt to send signal to

View file

@ -315,7 +315,7 @@ fhandler_process::fill_filebuf ()
case PROCESS_EXENAME:
{
filebuf = (char *) realloc (filebuf, bufalloc = CYG_MAX_PATH);
if (p->process_state & (PID_ZOMBIE | PID_EXITED))
if (p->process_state & PID_EXITED)
strcpy (filebuf, "<defunct>");
else
{
@ -380,7 +380,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
start_time = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
int priority = 0;
if (p->process_state & (PID_ZOMBIE | PID_EXITED))
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");
else
{
@ -400,7 +400,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
* Note: under Windows, a _process_ is always running - it's only _threads_
* that get suspended. Therefore the default state is R (runnable).
*/
if (p->process_state & PID_ZOMBIE)
if (p->process_state & PID_EXITED)
state = 'Z';
else if (p->process_state & PID_STOPPED)
state = 'T';
@ -513,7 +513,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
const char *state_str = "unknown";
unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL,
vmshare = 0UL;
if (p->process_state & (PID_ZOMBIE | PID_EXITED))
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");
else
{
@ -533,7 +533,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
* Note: under Windows, a _process_ is always running - it's only _threads_
* that get suspended. Therefore the default state is R (runnable).
*/
if (p->process_state & PID_ZOMBIE)
if (p->process_state & PID_EXITED)
state = 'Z';
else if (p->process_state & PID_STOPPED)
state = 'T';

View file

@ -88,7 +88,7 @@ unsigned long cygwin_internal (cygwin_getinfo_types, ...);
enum
{
PID_IN_USE = 0x00001, /* Entry in use. */
PID_ZOMBIE = 0x00002, /* Child exited: no parent wait. */
PID_UNUSED = 0x00002, /* Available. */
PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */
PID_TTYIN = 0x00008, /* Waiting for terminal input. */
PID_TTYOU = 0x00010, /* Waiting for terminal output. */

View file

@ -111,7 +111,6 @@ extern "C" int WINAPI
dll_entry (HANDLE h, DWORD reason, void *static_load)
{
BOOL is_64bit_machine = FALSE;
extern HANDLE hExeced;
switch (reason)
{

View file

@ -105,19 +105,17 @@ pinfo_init (char **envp, int envc)
# define self (*this)
void
pinfo::set_exit_state (DWORD pidstate)
pinfo::set_exit_state ()
{
DWORD x = 0xdeadbeef;
DWORD oexitcode = self->exitcode;
if (hProcess && self->exitcode == EXITCODE_UNSET)
if (hProcess && !(self->exitcode & EXITCODE_SET))
{
GetExitCodeProcess (hProcess, &x);
self->exitcode = (x & 0xff) << 8;
self->exitcode = EXITCODE_SET | (x & 0xff) << 8;
}
sigproc_printf ("exit value - old %p, windows %p, cygwin %p", oexitcode, x,
self->exitcode);
if (self->exitcode != EXITCODE_NOSET)
self->process_state = pidstate;
}
void
@ -125,10 +123,10 @@ pinfo::exit (DWORD n)
{
exit_state = ES_FINAL;
cygthread::terminate ();
if (n != EXITCODE_EXEC)
if (n != EXITCODE_NOSET)
{
sigproc_terminate (); /* Just terminate signal and process stuff */
self->exitcode = n; /* We're really exiting. Record the UNIX exit code. */
sigproc_terminate (); /* Just terminate signal and process stuff */
self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */
}
/* FIXME: There is a potential race between an execed process and its
@ -137,8 +135,8 @@ pinfo::exit (DWORD n)
fill_rusage (&r, hMainProc);
add_rusage (&self->rusage_self, &r);
set_exit_state (PID_EXITED);
if (n != EXITCODE_EXEC)
set_exit_state ();
if (n != EXITCODE_NOSET)
self->alert_parent (0);
int exitcode = self->exitcode;
release ();
@ -279,10 +277,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
if (!created)
/* nothing */;
else if (!(flag & PID_EXECED))
{
procinfo->pid = n;
procinfo->exitcode = EXITCODE_UNSET;
}
procinfo->pid = n;
else
{
procinfo->process_state |= PID_IN_USE | PID_EXECED;
@ -719,7 +714,8 @@ proc_waiter (void *arg)
/* Child exited. Do some cleanup and signal myself. */
CloseHandle (vchild.rd_proc_pipe);
vchild.rd_proc_pipe = NULL;
vchild.set_exit_state (PID_ZOMBIE);
vchild.set_exit_state ();
vchild->process_state = PID_EXITED;
if (WIFEXITED (vchild->exitcode))
si.si_sigval.sival_int = CLD_EXITED;
else if (WCOREDUMP (vchild->exitcode))

View file

@ -26,9 +26,8 @@ enum picom
PICOM_FIFO = 2
};
#define EXITCODE_UNSET 0x80000000
#define EXITCODE_NOSET EXITCODE_UNSET
#define EXITCODE_EXEC EXITCODE_UNSET
#define EXITCODE_SET 0x80000000
#define EXITCODE_NOSET 0x40000000
class _pinfo
{
@ -156,7 +155,7 @@ public:
release ();
}
void exit (DWORD n) __attribute__ ((noreturn, regparm(2)));
void set_exit_state (DWORD) __attribute__ ((regparm(2)));
void set_exit_state () __attribute__ ((regparm(2)));
void initialize_lock () {InitializeCriticalSection (&_lock);}
void lock () {EnterCriticalSection (&_lock);}
void unlock () {LeaveCriticalSection (&_lock);}

View file

@ -200,7 +200,7 @@ pid_exists (pid_t pid)
bool __stdcall
proc_exists (_pinfo *p)
{
return p && !(p->process_state & (PID_EXITED | PID_ZOMBIE));
return p && !(p->process_state & PID_EXITED);
}
/* Return true if this is one of our children, false otherwise. */
@ -891,7 +891,7 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
int terminated;
if (!((terminated = (child->process_state == PID_ZOMBIE)) ||
if (!((terminated = (child->process_state == PID_EXITED)) ||
((w->options & WUNTRACED) && child->stopsig)))
return 0;
@ -904,9 +904,9 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
w->status = (child->stopsig << 8) | 0x7f;
child->stopsig = 0;
}
else /* Should only get here when child has been moved to the procs array */
else
{
w->status = child->exitcode;
w->status = (__uint16_t) child->exitcode;
add_rusage (&myself->rusage_children, &child->rusage_children);
add_rusage (&myself->rusage_children, &child->rusage_self);

View file

@ -873,7 +873,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
myself.remember (false);
waitpid (myself->pid, &res, 0);
}
myself.exit (EXITCODE_EXEC);
myself.exit (EXITCODE_NOSET);
break;
case _P_WAIT:
case _P_SYSTEM: