* dcrt0.cc (dll_crt0_1): Move set_os_type.
(_dll_crt0): To here. (cygwin_dll_init): And here. * external.cc (fillout_pinfo): Use more foolproof method for scanning for pids. * pinfo.cc (set_myself): Eliminate myself_identity.init. * sigproc.cc (wait_sig): Do it here instead to reduce the amount of time where there could potentially be two processes with the same pid. * spawn.cc (spawn_guts): Eliminate duplicate initialization. * include/sys/cygwin.h: Mark unused PID_* elements.
This commit is contained in:
parent
14d3488d1f
commit
3c2c374555
|
@ -1,3 +1,16 @@
|
|||
Fri Aug 25 21:25:32 2000 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* dcrt0.cc (dll_crt0_1): Move set_os_type.
|
||||
(_dll_crt0): To here.
|
||||
(cygwin_dll_init): And here.
|
||||
* external.cc (fillout_pinfo): Use more foolproof method for scanning
|
||||
for pids.
|
||||
* pinfo.cc (set_myself): Eliminate myself_identity.init.
|
||||
* sigproc.cc (wait_sig): Do it here instead to reduce the amount of
|
||||
time where there could potentially be two processes with the same pid.
|
||||
* spawn.cc (spawn_guts): Eliminate duplicate initialization.
|
||||
* include/sys/cygwin.h: Mark unused PID_* elements.
|
||||
|
||||
Fri Aug 25 21:49:00 2000 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* exec.cc (_execve): Change definition according to declaration in
|
||||
|
|
|
@ -646,9 +646,6 @@ dll_crt0_1 ()
|
|||
user_data->threadinterface->Init0();
|
||||
#endif
|
||||
|
||||
/* Set the os_being_run global. */
|
||||
set_os_type ();
|
||||
|
||||
/* Initialize the host dependent constants object. */
|
||||
host_dependent.init ();
|
||||
|
||||
|
@ -811,6 +808,9 @@ _dll_crt0 ()
|
|||
init_exceptions (&cygwin_except_entry);
|
||||
do_global_ctors (&__CTOR_LIST__, 1);
|
||||
|
||||
/* Set the os_being_run global. */
|
||||
set_os_type ();
|
||||
|
||||
#ifdef DEBUGGING
|
||||
char buf[80];
|
||||
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf)))
|
||||
|
@ -922,6 +922,9 @@ cygwin_dll_init ()
|
|||
init_exceptions (&cygwin_except_entry);
|
||||
do_global_ctors (&__CTOR_LIST__, 1);
|
||||
|
||||
/* Set the os_being_run global. */
|
||||
set_os_type ();
|
||||
|
||||
user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
|
||||
|
||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
||||
|
|
|
@ -31,64 +31,54 @@ fillout_pinfo (pid_t pid, int winpid)
|
|||
if (!pids.npids)
|
||||
pids.init ();
|
||||
|
||||
static unsigned int i = 0;
|
||||
if (!pid)
|
||||
i = 0;
|
||||
|
||||
memset (&ep, 0, sizeof ep);
|
||||
for (unsigned i = 0; i < pids.npids; i++)
|
||||
for (; i < pids.npids; )
|
||||
{
|
||||
if (!pids[i])
|
||||
DWORD thispid = pids[i++];
|
||||
if (!thispid)
|
||||
continue;
|
||||
pinfo p (pids[i]);
|
||||
pid_t thispid;
|
||||
pinfo p (thispid);
|
||||
|
||||
if (p)
|
||||
thispid = p->pid;
|
||||
else if (winpid)
|
||||
thispid = pids[i];
|
||||
else
|
||||
continue;
|
||||
|
||||
if (!pid || thispid == pid)
|
||||
if (!p)
|
||||
{
|
||||
if (nextpid && pid)
|
||||
{
|
||||
pid = 0;
|
||||
nextpid = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!p)
|
||||
{
|
||||
ep.pid = pids[i];
|
||||
ep.dwProcessId = cygwin_pid (pids[i]);
|
||||
ep.process_state = PID_IN_USE;
|
||||
ep.ctty = -1;
|
||||
}
|
||||
else if (p->pid && NOTSTATE(p, PID_CLEAR))
|
||||
{
|
||||
ep.ctty = tty_attached (p) ? p->ctty : -1;
|
||||
ep.pid = p->pid;
|
||||
ep.ppid = p->ppid;
|
||||
ep.hProcess = p->hProcess;
|
||||
ep.dwProcessId = p->dwProcessId;
|
||||
ep.uid = p->uid;
|
||||
ep.gid = p->gid;
|
||||
ep.pgid = p->pgid;
|
||||
ep.sid = p->sid;
|
||||
ep.umask = p->umask;
|
||||
ep.start_time = p->start_time;
|
||||
ep.rusage_self = p->rusage_self;
|
||||
ep.rusage_children = p->rusage_children;
|
||||
strcpy (ep.progname, p->progname);
|
||||
ep.strace_mask = 0;
|
||||
ep.strace_file = 0;
|
||||
|
||||
ep.process_state = p->process_state;
|
||||
}
|
||||
break;
|
||||
if (!winpid)
|
||||
continue;
|
||||
ep.pid = thispid;
|
||||
ep.dwProcessId = cygwin_pid (thispid);
|
||||
ep.process_state = PID_IN_USE;
|
||||
ep.ctty = -1;
|
||||
}
|
||||
else if (p->pid)
|
||||
{
|
||||
ep.ctty = tty_attached (p) ? p->ctty : -1;
|
||||
ep.pid = p->pid;
|
||||
ep.ppid = p->ppid;
|
||||
ep.hProcess = p->hProcess;
|
||||
ep.dwProcessId = p->dwProcessId;
|
||||
ep.uid = p->uid;
|
||||
ep.gid = p->gid;
|
||||
ep.pgid = p->pgid;
|
||||
ep.sid = p->sid;
|
||||
ep.umask = p->umask;
|
||||
ep.start_time = p->start_time;
|
||||
ep.rusage_self = p->rusage_self;
|
||||
ep.rusage_children = p->rusage_children;
|
||||
strcpy (ep.progname, p->progname);
|
||||
ep.strace_mask = 0;
|
||||
ep.strace_file = 0;
|
||||
|
||||
ep.process_state = p->process_state;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ep.pid)
|
||||
{
|
||||
i = 0;
|
||||
pids.reset ();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -81,14 +81,14 @@ enum
|
|||
PID_CYGPARENT = 0x0080, // Set if parent was a cygwin app.
|
||||
PID_SPLIT_HEAP = 0x0100, // Set if the heap has been split,
|
||||
// which means we can't fork again.
|
||||
PID_CLEAR = 0x0200, // Flag that pid should be cleared from parent's
|
||||
PID_UNUSED = 0x0200, // Flag that pid should be cleared from parent's
|
||||
// wait list
|
||||
PID_SOCKETS_USED = 0x0400, // Set if process uses Winsock.
|
||||
PID_UNUSED1 = 0x0400, // Set if process uses Winsock.
|
||||
PID_INITIALIZING = 0x0800, // Set until ready to receive signals.
|
||||
PID_USETTY = 0x1000, // Setting this enables or disables cygwin's
|
||||
// tty support. This is inherited by
|
||||
// all execed or forked processes.
|
||||
PID_REPARENT = 0x2000, // child has execed
|
||||
PID_UNUSED2 = 0x2000, // child has execed
|
||||
PID_EXECED = 0x4000, // redirect to original pid info block
|
||||
PID_NOREDIR = 0x8000 // don't redirect if execed
|
||||
};
|
||||
|
|
|
@ -24,7 +24,6 @@ details. */
|
|||
static char NO_COPY pinfo_dummy[sizeof(pinfo)] = {0};
|
||||
|
||||
pinfo NO_COPY myself ((_pinfo *)&pinfo_dummy); // Avoid myself != NULL checks
|
||||
static pinfo NO_COPY myself_identity ((_pinfo *)&pinfo_dummy);
|
||||
|
||||
/* Initialize the process table.
|
||||
This is done once when the dll is first loaded. */
|
||||
|
@ -39,9 +38,6 @@ set_myself (pid_t pid, HANDLE h)
|
|||
myself->dwProcessId = winpid;
|
||||
myself->process_state |= PID_IN_USE;
|
||||
myself->start_time = time (NULL); /* Register our starting time. */
|
||||
pid_t myself_cyg_pid = cygwin_pid (myself->dwProcessId);
|
||||
if (pid != myself_cyg_pid && parent_alive)
|
||||
myself_identity.init (myself_cyg_pid, PID_EXECED);
|
||||
|
||||
char buf[30];
|
||||
__small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR,
|
||||
|
@ -95,7 +91,7 @@ pinfo_init (LPBYTE info)
|
|||
{
|
||||
/* Invent our own pid. */
|
||||
|
||||
set_myself (1, NULL);
|
||||
set_myself (1);
|
||||
myself->ppid = 1;
|
||||
myself->pgid = myself->sid = myself->pid;
|
||||
myself->ctty = -1;
|
||||
|
|
|
@ -1202,6 +1202,11 @@ wait_sig (VOID *)
|
|||
if (!SetEvent (child_proc_info->subproc_ready))
|
||||
system_printf ("SetEvent (subproc_ready) failed, %E");
|
||||
ForceCloseHandle (child_proc_info->subproc_ready);
|
||||
/* Initialize an "indirect" pid block so that if someone looks up this
|
||||
process via its Windows PID it will be redirected to the appropriate
|
||||
Cygwin PID shared memory block. */
|
||||
static pinfo NO_COPY myself_identity;
|
||||
myself_identity.init (cygwin_pid (myself->dwProcessId), PID_EXECED);
|
||||
}
|
||||
|
||||
SetEvent (wait_sig_inited);
|
||||
|
|
|
@ -655,14 +655,14 @@ skip_arg_parsing:
|
|||
proc_terminate ();
|
||||
hExeced = pi.hProcess;
|
||||
|
||||
/* Set up child's signal handlers */
|
||||
/* CGF FIXME - consolidate with signal stuff below */
|
||||
for (i = 0; i < NSIG; i++)
|
||||
{
|
||||
myself->getsig(i).sa_mask = 0;
|
||||
if (myself->getsig(i).sa_handler != SIG_IGN || (mode != _P_OVERLAY))
|
||||
myself->getsig(i).sa_handler = SIG_DFL;
|
||||
}
|
||||
/* Set up child's signal handlers */
|
||||
/* CGF FIXME - consolidate with signal stuff below */
|
||||
for (i = 0; i < NSIG; i++)
|
||||
{
|
||||
myself->getsig(i).sa_mask = 0;
|
||||
if (myself->getsig(i).sa_handler != SIG_IGN || (mode != _P_OVERLAY))
|
||||
myself->getsig(i).sa_handler = SIG_DFL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -696,7 +696,6 @@ skip_arg_parsing:
|
|||
child->rootlen = myself->rootlen;
|
||||
child->dwProcessId = pi.dwProcessId;
|
||||
child->hProcess = pi.hProcess;
|
||||
child->process_state |= PID_INITIALIZING;
|
||||
for (i = 0; i < NSIG; i++)
|
||||
{
|
||||
child->getsig(i).sa_mask = 0;
|
||||
|
|
Loading…
Reference in New Issue