4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-18 23:12:15 +08:00

* 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> 2005-01-15 Christopher Faylor <cgf@timesys.com>
* sigproc.cc (sig_send): Don't complain if attempt to send signal to * 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: case PROCESS_EXENAME:
{ {
filebuf = (char *) realloc (filebuf, bufalloc = CYG_MAX_PATH); 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>"); strcpy (filebuf, "<defunct>");
else else
{ {
@ -380,7 +380,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
start_time = 0UL, start_time = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL; vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
int priority = 0; int priority = 0;
if (p->process_state & (PID_ZOMBIE | PID_EXITED)) if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>"); strcpy (cmd, "<defunct>");
else 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_ * Note: under Windows, a _process_ is always running - it's only _threads_
* that get suspended. Therefore the default state is R (runnable). * that get suspended. Therefore the default state is R (runnable).
*/ */
if (p->process_state & PID_ZOMBIE) if (p->process_state & PID_EXITED)
state = 'Z'; state = 'Z';
else if (p->process_state & PID_STOPPED) else if (p->process_state & PID_STOPPED)
state = 'T'; state = 'T';
@ -513,7 +513,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
const char *state_str = "unknown"; const char *state_str = "unknown";
unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL, unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL,
vmshare = 0UL; vmshare = 0UL;
if (p->process_state & (PID_ZOMBIE | PID_EXITED)) if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>"); strcpy (cmd, "<defunct>");
else 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_ * Note: under Windows, a _process_ is always running - it's only _threads_
* that get suspended. Therefore the default state is R (runnable). * that get suspended. Therefore the default state is R (runnable).
*/ */
if (p->process_state & PID_ZOMBIE) if (p->process_state & PID_EXITED)
state = 'Z'; state = 'Z';
else if (p->process_state & PID_STOPPED) else if (p->process_state & PID_STOPPED)
state = 'T'; state = 'T';

View File

@ -88,7 +88,7 @@ unsigned long cygwin_internal (cygwin_getinfo_types, ...);
enum enum
{ {
PID_IN_USE = 0x00001, /* Entry in use. */ 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_STOPPED = 0x00004, /* Waiting for SIGCONT. */
PID_TTYIN = 0x00008, /* Waiting for terminal input. */ PID_TTYIN = 0x00008, /* Waiting for terminal input. */
PID_TTYOU = 0x00010, /* Waiting for terminal output. */ 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) dll_entry (HANDLE h, DWORD reason, void *static_load)
{ {
BOOL is_64bit_machine = FALSE; BOOL is_64bit_machine = FALSE;
extern HANDLE hExeced;
switch (reason) switch (reason)
{ {

View File

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

View File

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

View File

@ -200,7 +200,7 @@ pid_exists (pid_t pid)
bool __stdcall bool __stdcall
proc_exists (_pinfo *p) 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. */ /* 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; int terminated;
if (!((terminated = (child->process_state == PID_ZOMBIE)) || if (!((terminated = (child->process_state == PID_EXITED)) ||
((w->options & WUNTRACED) && child->stopsig))) ((w->options & WUNTRACED) && child->stopsig)))
return 0; return 0;
@ -904,9 +904,9 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
w->status = (child->stopsig << 8) | 0x7f; w->status = (child->stopsig << 8) | 0x7f;
child->stopsig = 0; 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_children);
add_rusage (&myself->rusage_children, &child->rusage_self); 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); myself.remember (false);
waitpid (myself->pid, &res, 0); waitpid (myself->pid, &res, 0);
} }
myself.exit (EXITCODE_EXEC); myself.exit (EXITCODE_NOSET);
break; break;
case _P_WAIT: case _P_WAIT:
case _P_SYSTEM: case _P_SYSTEM: