public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop PROC_DETACHED_CHILD flag Date: Fri, 28 Aug 2020 13:23:59 +0000 (GMT) [thread overview] Message-ID: <20200828132359.7F8713861002@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=163daed37ceda6cd32838ee0137026d68e8ffb18 commit 163daed37ceda6cd32838ee0137026d68e8ffb18 Author: Corinna Vinschen <corinna@vinschen.de> Date: Fri Aug 28 11:10:48 2020 +0200 Cygwin: drop PROC_DETACHED_CHILD flag pinfo::remember with the detach parameter set to true is the only way to call proc_subproc with PROC_DETACHED_CHILD. This call is exclusively used in spawn to set up a pinfo for a detached child, and that pinfo goes out of scope right afterwards without any further action. Drop the flag and drop the detach parameter from pinfo::remember. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/fork.cc | 2 +- winsup/cygwin/pinfo.h | 5 ++--- winsup/cygwin/sigproc.cc | 8 ++------ winsup/cygwin/sigproc.h | 9 ++++----- winsup/cygwin/spawn.cc | 5 ++--- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 43a92738c..719217856 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -415,7 +415,7 @@ frok::parent (volatile char * volatile stack_here) it in afterwards. This requires more bookkeeping than I like, though, so we'll just do it the easy way. So, terminate any child process if we can't actually record the pid in the internal table. */ - if (!child.remember (false)) + if (!child.remember ()) { this_errno = EAGAIN; #ifdef DEBUGGING0 diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 2db7d6a01..69c1223f3 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -196,10 +196,9 @@ public: destroy = res ? false : true; return res; } - int remember (bool detach) + int remember () { - int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADD_CHILD, - (uintptr_t) this); + int res = proc_subproc (PROC_ADD_CHILD, (uintptr_t) this); destroy = res ? false : true; return res; } diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 7679f76f4..ba1e64b33 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -205,9 +205,6 @@ proc_subproc (DWORD what, uintptr_t val) set_errno (EAGAIN); break; } - fallthrough; - - case PROC_DETACHED_CHILD: if (vchild != myself) { vchild->uid = myself->uid; @@ -217,8 +214,7 @@ proc_subproc (DWORD what, uintptr_t val) vchild->ctty = myself->ctty; vchild->cygstarted = true; vchild->process_state |= PID_INITIALIZING; - vchild->ppid = what == PROC_DETACHED_CHILD - ? 1 : myself->pid; /* always set last */ + vchild->ppid = myself->pid; /* always set last */ } break; @@ -879,7 +875,7 @@ void child_info_spawn::wait_for_myself () { postfork (myself); - if (myself.remember (false)) + if (myself.remember ()) myself.attach (); WaitForSingleObject (ev, INFINITE); } diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 3d4e766a2..2a3d248d1 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -33,11 +33,10 @@ enum procstuff PROC_ADD_CHILD = 1, // set up a new child PROC_ATTACH_CHILD = 2, // attach child or reattach after exec PROC_EXEC_CLEANUP = 3, // cleanup waiting children after exec - PROC_DETACHED_CHILD = 4, // set up a detached child - PROC_CLEARWAIT = 5, // clear all waits - signal arrived - PROC_WAIT = 6, // setup for wait() for subproc - PROC_EXECING = 7, // used to get a lock when execing - PROC_NOTHING = 8 // nothing, really + PROC_CLEARWAIT = 4, // clear all waits - signal arrived + PROC_WAIT = 5, // setup for wait() for subproc + PROC_EXECING = 6, // used to get a lock when execing + PROC_NOTHING = 7 // nothing, really }; struct sigpacket diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 1efcdb366..a2f7697d7 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -867,9 +867,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, child->start_time = time (NULL); /* Register child's starting time. */ child->nice = myself->nice; postfork (child); - if (mode == _P_DETACH - ? !child.remember (true) - : !(child.remember (false) && child.attach ())) + if (mode != _P_DETACH + && (!child.remember () || !child.attach ())) { /* FIXME: Child in strange state now */ CloseHandle (pi.hProcess);
reply other threads:[~2020-08-28 13:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200828132359.7F8713861002@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).