Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-03-20 19:07:30 +0400
committerChristopher Faylor <me@cgf.cx>2012-03-20 19:07:30 +0400
commit1fb6667f1ca346ab7f845b1adcb146a7d6e243fc (patch)
treed7619da1a2bce1baf30740f17e7b4690e5996466 /winsup/cygwin/pinfo.cc
parente9a6f9c6259960156a999ab2b207adf7ede1a088 (diff)
* child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info::rd_proc_pipe): Declare new field. (child_info::wr_proc_pipe): Ditto. (child_info::prefork): Declare new function, derived from previous pinfo version. * dcrt0.cc (child_info_fork::handle_fork): Close previous wr_proc_pipe when appropriate and assign new one from passed-in child_info block. (child_info_spawn::handle_spawn): Assign our wr_proc_pipe handle from passed-in child_info block. * fork.cc (child_info::prefork): Define new function. (frok::child): Clear rd_proc_pipe and wr_proc_pipe so they will not be closed by the child_info destructor. (frok::parent): Use child_info prefork handling, outside of retry loop. Set rd_proc_pipe in child's pinfo after successful CreateProcess. Eliminate postfork call. * globals.cc (my_wr_proc_pipe): Define/declare new variable. * pinfo.cc (pinfo::pending_rd_proc_pipe): Delete. (pinfo::pending_wr_proc_pipe): Ditto. (pinfo::prefork): Ditto. (pinfo::postfork): Ditto. (pinfo::postexec): Ditto. (pinfo::wait): Assume that rd_proc_pipe is set up correctly prior to call. (_pinfo::alert_parent): Replace "wr_proc_pipe" with "my_wr_proc_pipe". * pinfo.h (_pinfo::_wr_proc_pipe): Delete declaration. (_pinfo::set_rd_proc_pipe): Define new function. (pinfo::pending_rd_proc_pipe): Delete declaration. (pinfo::pending_wr_proc_pipe): Ditto. (pinfo::prefork): Ditto. (pinfo::postfork): Ditto. (pinfo::postexec): Ditto. (pinfo::wr_proc_pipe): Ditto. * sigproc.cc (child_info::child_info): Clear rd_proc_pipe and wr_proc_pipe. (child_info::cleanup): Close rd_proc_pipe and wr_proc_pipe if necessary. (child_info_fork::child_info_fork): Set forker_finished to NULL by default. (child_info_spawn::child_info_spawn): Use my_wr_proc_pipe rather than myself->wr_proc_pipe. (child_info::sync): Ditto. (child_info_spawn::cleanup): Call child_info::cleanup. * spawn.cc (child_info_spawn::worker): Remove call to myself.prefork(). Set wr_proc_pipe when execing or set up new rd_proc_pipe/wr_proc_pipe via child_info::prefork when spawning. Remove call to pinfo::postexec. Set rd_proc_pipe in child pinfo when spawning. Use my_wr_proc_pipe rather than myself->wr_proc_pipe. Remove call to postfork.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc77
1 files changed, 4 insertions, 73 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 10910f3ce..2c6910957 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -49,9 +49,6 @@ pinfo_basic myself_initial NO_COPY;
pinfo NO_COPY myself (static_cast<_pinfo *> (&myself_initial)); // Avoid myself != NULL checks
-HANDLE NO_COPY pinfo::pending_rd_proc_pipe;
-HANDLE NO_COPY pinfo::pending_wr_proc_pipe;
-
bool is_toplevel_proc;
/* Setup the pinfo structure for this process. There may already be a
@@ -989,22 +986,6 @@ debug_printf ("%d exited buf %d\n", vchild->pid, buf);
bool
pinfo::wait ()
{
- /* If pending_rd_proc_pipe == NULL we're in an execed process which has
- already grabbed the read end of the pipe from the previous cygwin process
- running with this pid. */
- if (pending_rd_proc_pipe)
- {
- /* Our end of the pipe, previously set in prefork() . */
- rd_proc_pipe = pending_rd_proc_pipe;
- pending_rd_proc_pipe = NULL;
-
- /* This sets wr_proc_pipe in the child which, after the following
- ForceCloseHandle1, will be only process with the handle open. */
- wr_proc_pipe () = pending_wr_proc_pipe;
- ForceCloseHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
- pending_wr_proc_pipe = NULL;
- }
-
preserve (); /* Preserve the shared memory associated with the pinfo */
waiter_ready = false;
@@ -1022,54 +1003,6 @@ pinfo::wait ()
return true;
}
-void
-pinfo::prefork (bool detached)
-{
- if (wr_proc_pipe () && wr_proc_pipe () != INVALID_HANDLE_VALUE
- && !SetHandleInformation (wr_proc_pipe (), HANDLE_FLAG_INHERIT, 0))
- api_fatal ("couldn't set process pipe(%p) inherit state, %E", wr_proc_pipe ());
- if (!detached)
- {
- if (!CreatePipe (&pending_rd_proc_pipe, &pending_wr_proc_pipe,
- &sec_none_nih, 16))
- api_fatal ("Couldn't create pipe tracker for pid %d, %E", (*this)->pid);
-
- if (!SetHandleInformation (pending_wr_proc_pipe, HANDLE_FLAG_INHERIT,
- HANDLE_FLAG_INHERIT))
- api_fatal ("prefork: couldn't set process pipe(%p) inherit state, %E",
- pending_wr_proc_pipe);
- ProtectHandle1 (pending_rd_proc_pipe, rd_proc_pipe);
- ProtectHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
- }
-}
-
-void
-pinfo::postfork ()
-{
- if (wr_proc_pipe () && wr_proc_pipe () != INVALID_HANDLE_VALUE
- && !SetHandleInformation (wr_proc_pipe (), HANDLE_FLAG_INHERIT,
- HANDLE_FLAG_INHERIT))
- api_fatal ("postfork: couldn't set process pipe(%p) inherit state, %E", wr_proc_pipe ());
- if (pending_rd_proc_pipe)
- {
- ForceCloseHandle1 (pending_rd_proc_pipe, rd_proc_pipe);
- pending_rd_proc_pipe = NULL;
- }
- if (pending_wr_proc_pipe)
- {
- ForceCloseHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
- pending_wr_proc_pipe = NULL;
- }
-}
-
-void
-pinfo::postexec ()
-{
- if (wr_proc_pipe () && wr_proc_pipe () != INVALID_HANDLE_VALUE
- && !ForceCloseHandle1 (wr_proc_pipe (), wr_proc_pipe))
- api_fatal ("postexec: couldn't close wr_proc_pipe(%p), %E", wr_proc_pipe ());
-}
-
/* function to send a "signal" to the parent when something interesting happens
in the child. */
bool
@@ -1082,19 +1015,17 @@ _pinfo::alert_parent (char sig)
FIXME: Is there a race here if we run this while another thread is attempting
to exec()? */
- if (wr_proc_pipe == INVALID_HANDLE_VALUE || !myself.wr_proc_pipe () || have_execed)
- /* no parent */;
- else
+ if (my_wr_proc_pipe)
{
- if (WriteFile (wr_proc_pipe, &sig, 1, &nb, NULL))
+ if (WriteFile (my_wr_proc_pipe, &sig, 1, &nb, NULL))
/* all is well */;
else if (GetLastError () != ERROR_BROKEN_PIPE)
debug_printf ("sending %d notification to parent failed, %E", sig);
else
{
ppid = 1;
- HANDLE closeit = wr_proc_pipe;
- wr_proc_pipe = INVALID_HANDLE_VALUE;
+ HANDLE closeit = my_wr_proc_pipe;
+ my_wr_proc_pipe = NULL;
ForceCloseHandle1 (closeit, wr_proc_pipe);
}
}