diff options
author | Christopher Faylor <me@cgf.cx> | 2004-12-06 00:29:41 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2004-12-06 00:29:41 +0000 |
commit | 8c43a9f82e078662b70a1777f232edd7b37dfa02 (patch) | |
tree | 3b291a9542f6cf4ab3b13c76f0777e3023e7f4be | |
parent | 013f043fff95d2f456f97b81cd3bd4ee02000cc0 (diff) | |
download | newlib-8c43a9f82e078662b70a1777f232edd7b37dfa02.zip newlib-8c43a9f82e078662b70a1777f232edd7b37dfa02.tar.gz newlib-8c43a9f82e078662b70a1777f232edd7b37dfa02.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 13 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.h | 7 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 11 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 5 |
6 files changed, 25 insertions, 16 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9b99c6b..51a4675 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,18 @@ 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. * pinfo.h (pinfo::wait_thread): New element. * pinfo.cc (pinfo::wait): Store "handle" to started thread in pinfo. diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 422b191..770c6c2 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -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; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 8d6a7da..eac27e9 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -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); diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index e460eed..76f5f77 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -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 () diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index bc1d6ff..7b3ba89 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -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); } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index b161b98..f0187e2 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -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: |