mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* fork.cc (fork_parent): Reinstate "childhProc" protection. Don't close
hProcess handle here since it is used to ensure that a new process isn't created with the old pid after the old pid exits. * spawn.cc (spawn_guts): Ditto. * pinfo.cc (proc_waiter): Don't send any signals if we've execed since this process doesn't officially exist. * pinfo.h (pinfo::pid_handle): Eliminate. Just use hProc. * sigproc.cc (sig_send): Don't send any signals if our sendsig doesn't exist. That's a sign that we are execing. (remove_proc): Eliminate pid_handle close.
This commit is contained in:
parent
013f043fff
commit
8c43a9f82e
@ -1,3 +1,16 @@
|
||||
2004-12-05 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* fork.cc (fork_parent): Reinstate "childhProc" protection. Don't
|
||||
close hProcess handle here since it is used to ensure that a new
|
||||
process isn't created with the old pid after the old pid exits.
|
||||
* spawn.cc (spawn_guts): Ditto.
|
||||
* pinfo.cc (proc_waiter): Don't send any signals if we've execed since
|
||||
this process doesn't officially exist.
|
||||
* pinfo.h (pinfo::pid_handle): Eliminate. Just use hProc.
|
||||
* sigproc.cc (sig_send): Don't send any signals if our sendsig doesn't
|
||||
exist. That's a sign that we are execing.
|
||||
(remove_proc): Eliminate pid_handle close.
|
||||
|
||||
2004-12-05 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* cygthread.h (cygthread::terminate_thread): Make public.
|
||||
|
@ -402,7 +402,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||
ProtectHandle (pi.hThread);
|
||||
/* Protect the handle but name it similarly to the way it will
|
||||
be called in subproc handling. */
|
||||
ProtectHandle (pi.hProcess);
|
||||
ProtectHandle1 (pi.hProcess, childhProc);
|
||||
|
||||
/* Fill in fields in the child's process table entry. */
|
||||
child->dwProcessId = pi.dwProcessId;
|
||||
@ -501,7 +501,6 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
||||
(void) resume_child (forker_finished);
|
||||
}
|
||||
|
||||
ForceCloseHandle (pi.hProcess);
|
||||
ForceCloseHandle (pi.hThread);
|
||||
ForceCloseHandle (forker_finished);
|
||||
forker_finished = NULL;
|
||||
|
@ -742,7 +742,7 @@ proc_waiter (void *arg)
|
||||
/* Special case: If the "child process" that died is us, then we're
|
||||
execing. Just call proc_subproc directly and then exit this loop.
|
||||
We're done here. */
|
||||
if (hExeced && vchild->pid == myself->pid)
|
||||
if (hExeced)
|
||||
{
|
||||
/* execing. no signals available now. */
|
||||
proc_subproc (PROC_CLEARWAIT, 0);
|
||||
|
@ -136,13 +136,12 @@ public:
|
||||
HANDLE hProcess;
|
||||
CRITICAL_SECTION _lock;
|
||||
/* Handle associated with initial Windows pid which started it all. */
|
||||
HANDLE pid_handle;
|
||||
class cygthread *wait_thread;
|
||||
void init (pid_t, DWORD, HANDLE = NULL) __attribute__ ((regparm(3)));
|
||||
pinfo () {}
|
||||
pinfo (_pinfo *x): procinfo (x), hProcess (NULL), pid_handle (NULL) {}
|
||||
pinfo (pid_t n) : rd_proc_pipe (NULL), hProcess (NULL), pid_handle (NULL) {init (n, 0);}
|
||||
pinfo (pid_t n, DWORD flag) : rd_proc_pipe (NULL), hProcess (NULL), pid_handle (NULL) {init (n, flag);}
|
||||
pinfo (_pinfo *x): procinfo (x), hProcess (NULL) {}
|
||||
pinfo (pid_t n) : rd_proc_pipe (NULL), hProcess (NULL) {init (n, 0);}
|
||||
pinfo (pid_t n, DWORD flag) : rd_proc_pipe (NULL), hProcess (NULL) {init (n, flag);}
|
||||
void release ();
|
||||
int wait () __attribute__ ((regparm (1)));
|
||||
~pinfo ()
|
||||
|
@ -82,6 +82,8 @@ static bool __stdcall remove_proc (int);
|
||||
static bool __stdcall stopped_or_terminated (waitq *, _pinfo *);
|
||||
static DWORD WINAPI wait_sig (VOID *arg);
|
||||
|
||||
extern HANDLE hExeced;
|
||||
|
||||
/* wait_sig bookkeeping */
|
||||
|
||||
class pending_signals
|
||||
@ -501,7 +503,6 @@ sigproc_init ()
|
||||
void __stdcall
|
||||
sigproc_terminate (void)
|
||||
{
|
||||
extern HANDLE hExeced;
|
||||
hwait_sig = NULL;
|
||||
|
||||
if (myself->sendsig == INVALID_HANDLE_VALUE)
|
||||
@ -509,7 +510,6 @@ sigproc_terminate (void)
|
||||
else
|
||||
{
|
||||
sigproc_printf ("entering");
|
||||
// finished with anything it is doing
|
||||
if (!hExeced)
|
||||
{
|
||||
HANDLE sendsig = myself->sendsig;
|
||||
@ -545,6 +545,9 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
||||
sigpacket pack;
|
||||
|
||||
pack.wakeup = NULL;
|
||||
if (!myself->sendsig) // FIXME: This catches the exec case but what if the exec is going to fail?
|
||||
goto out;
|
||||
|
||||
bool wait_for_completion;
|
||||
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
||||
wait_for_completion = false;
|
||||
@ -657,7 +660,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
|
||||
{
|
||||
if (no_signals_available ())
|
||||
sigproc_printf ("I'm going away now");
|
||||
else
|
||||
else if (!hExeced)
|
||||
system_printf ("error sending signal %d to pid %d, pipe handle %p, %E",
|
||||
si.si_signo, p->pid, sendsig);
|
||||
}
|
||||
@ -857,8 +860,6 @@ remove_proc (int ci)
|
||||
if (procs[ci] != myself)
|
||||
{
|
||||
procs[ci].release ();
|
||||
if (procs[ci].pid_handle)
|
||||
ForceCloseHandle1 (procs[ci].pid_handle, childhProc);
|
||||
if (procs[ci].hProcess)
|
||||
ForceCloseHandle1 (procs[ci].hProcess, childhProc);
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
rc ? cygpid : (unsigned int) -1, prog_arg, one_line.buf);
|
||||
|
||||
/* Name the handle similarly to proc_subproc. */
|
||||
ProtectHandle (pi.hProcess);
|
||||
ProtectHandle1 (pi.hProcess, childhProc);
|
||||
|
||||
bool wait_for_myself = false;
|
||||
if (mode == _P_OVERLAY)
|
||||
@ -802,7 +802,6 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
this). */
|
||||
if (!myself->wr_proc_pipe)
|
||||
{
|
||||
myself.hProcess = pi.hProcess;
|
||||
myself.remember ();
|
||||
wait_for_myself = true;
|
||||
myself->wr_proc_pipe = INVALID_HANDLE_VALUE;
|
||||
@ -855,8 +854,6 @@ if (wait_for_myself)
|
||||
else
|
||||
ciresrv.sync (myself, INFINITE);
|
||||
|
||||
ForceCloseHandle (pi.hProcess);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case _P_OVERLAY:
|
||||
|
Loading…
x
Reference in New Issue
Block a user