Cygwin: fix up proc_subproc flags and matching pinfo methods
After patch 23a779bf3d7c2afc9eab88f6b8727c1db5544547 "Cygwin: pinfo: stop remember doing reattach", PROC_ADDCHILD actually just sets up a new child, mirroring PROC_DETACHED_CHILD. The actual attaching of the child is performed by action PROC_REATTACH_CHILD or pinfo::reattach respectively. To better reflect what's going on, rename PROC_REATTACH_CHILD to PROC_ATTACH_CHILD and rename pinfo::reattach to pinfo::attach. For better readability change PROC_ADDCHILD to PROC_ADD_CHILD. Fix comments accordingly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
49a9ffdf4b
commit
0a31ad6f4c
@ -509,11 +509,11 @@ frok::parent (volatile char * volatile stack_here)
|
|||||||
|
|
||||||
/* Do not attach to the child before it has successfully initialized.
|
/* Do not attach to the child before it has successfully initialized.
|
||||||
Otherwise we may wait forever, or deliver an orphan SIGCHILD. */
|
Otherwise we may wait forever, or deliver an orphan SIGCHILD. */
|
||||||
if (!child.reattach ())
|
if (!child.attach ())
|
||||||
{
|
{
|
||||||
this_errno = EAGAIN;
|
this_errno = EAGAIN;
|
||||||
#ifdef DEBUGGING0
|
#ifdef DEBUGGING0
|
||||||
error ("child reattach failed");
|
error ("child attach failed");
|
||||||
#endif
|
#endif
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -187,18 +187,18 @@ public:
|
|||||||
void preserve () { destroy = false; }
|
void preserve () { destroy = false; }
|
||||||
void allow_remove () { destroy = true; }
|
void allow_remove () { destroy = true; }
|
||||||
#ifndef SIG_BAD_MASK // kludge to ensure that sigproc.h included
|
#ifndef SIG_BAD_MASK // kludge to ensure that sigproc.h included
|
||||||
// int reattach () {system_printf ("reattach is not here"); return 0;}
|
// int attach () {system_printf ("attach is not here"); return 0;}
|
||||||
// int remember (bool) {system_printf ("remember is not here"); return 0;}
|
// int remember (bool) {system_printf ("remember is not here"); return 0;}
|
||||||
#else
|
#else
|
||||||
int reattach ()
|
int attach ()
|
||||||
{
|
{
|
||||||
int res = proc_subproc (PROC_REATTACH_CHILD, (uintptr_t) this);
|
int res = proc_subproc (PROC_ATTACH_CHILD, (uintptr_t) this);
|
||||||
destroy = res ? false : true;
|
destroy = res ? false : true;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
int remember (bool detach)
|
int remember (bool detach)
|
||||||
{
|
{
|
||||||
int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADDCHILD,
|
int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADD_CHILD,
|
||||||
(uintptr_t) this);
|
(uintptr_t) this);
|
||||||
destroy = res ? false : true;
|
destroy = res ? false : true;
|
||||||
return res;
|
return res;
|
||||||
|
@ -195,7 +195,7 @@ proc_subproc (DWORD what, uintptr_t val)
|
|||||||
/* Add a new subprocess to the children arrays.
|
/* Add a new subprocess to the children arrays.
|
||||||
* (usually called from the main thread)
|
* (usually called from the main thread)
|
||||||
*/
|
*/
|
||||||
case PROC_ADDCHILD:
|
case PROC_ADD_CHILD:
|
||||||
/* Filled up process table? */
|
/* Filled up process table? */
|
||||||
if (nprocs >= NPROCS)
|
if (nprocs >= NPROCS)
|
||||||
{
|
{
|
||||||
@ -217,11 +217,12 @@ proc_subproc (DWORD what, uintptr_t val)
|
|||||||
vchild->ctty = myself->ctty;
|
vchild->ctty = myself->ctty;
|
||||||
vchild->cygstarted = true;
|
vchild->cygstarted = true;
|
||||||
vchild->process_state |= PID_INITIALIZING;
|
vchild->process_state |= PID_INITIALIZING;
|
||||||
vchild->ppid = what == PROC_DETACHED_CHILD ? 1 : myself->pid; /* always set last */
|
vchild->ppid = what == PROC_DETACHED_CHILD
|
||||||
|
? 1 : myself->pid; /* always set last */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROC_REATTACH_CHILD:
|
case PROC_ATTACH_CHILD:
|
||||||
procs[nprocs] = vchild;
|
procs[nprocs] = vchild;
|
||||||
rc = procs[nprocs].wait ();
|
rc = procs[nprocs].wait ();
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -879,7 +880,7 @@ child_info_spawn::wait_for_myself ()
|
|||||||
{
|
{
|
||||||
postfork (myself);
|
postfork (myself);
|
||||||
if (myself.remember (false))
|
if (myself.remember (false))
|
||||||
myself.reattach ();
|
myself.attach ();
|
||||||
WaitForSingleObject (ev, INFINITE);
|
WaitForSingleObject (ev, INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +974,7 @@ cygheap_exec_info::reattach_children (HANDLE parent)
|
|||||||
pinfo p (parent, children[i].p, children[i].pid);
|
pinfo p (parent, children[i].p, children[i].pid);
|
||||||
if (!p)
|
if (!p)
|
||||||
debug_only_printf ("couldn't reattach child %d from previous process", children[i].pid);
|
debug_only_printf ("couldn't reattach child %d from previous process", children[i].pid);
|
||||||
else if (!p.reattach ())
|
else if (!p.attach ())
|
||||||
debug_only_printf ("attach of child process %d failed", children[i].pid);
|
debug_only_printf ("attach of child process %d failed", children[i].pid);
|
||||||
else
|
else
|
||||||
debug_only_printf ("reattached pid %d<%u>, process handle %p, rd_proc_pipe %p->%p",
|
debug_only_printf ("reattached pid %d<%u>, process handle %p, rd_proc_pipe %p->%p",
|
||||||
|
@ -30,8 +30,8 @@ enum
|
|||||||
|
|
||||||
enum procstuff
|
enum procstuff
|
||||||
{
|
{
|
||||||
PROC_ADDCHILD = 1, // add a new subprocess to list
|
PROC_ADD_CHILD = 1, // set up a new child
|
||||||
PROC_REATTACH_CHILD = 2, // reattach after exec
|
PROC_ATTACH_CHILD = 2, // attach child or reattach after exec
|
||||||
PROC_EXEC_CLEANUP = 3, // cleanup waiting children after exec
|
PROC_EXEC_CLEANUP = 3, // cleanup waiting children after exec
|
||||||
PROC_DETACHED_CHILD = 4, // set up a detached child
|
PROC_DETACHED_CHILD = 4, // set up a detached child
|
||||||
PROC_CLEARWAIT = 5, // clear all waits - signal arrived
|
PROC_CLEARWAIT = 5, // clear all waits - signal arrived
|
||||||
|
@ -869,7 +869,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
|
|||||||
postfork (child);
|
postfork (child);
|
||||||
if (mode == _P_DETACH
|
if (mode == _P_DETACH
|
||||||
? !child.remember (true)
|
? !child.remember (true)
|
||||||
: !(child.remember (false) && child.reattach ()))
|
: !(child.remember (false) && child.attach ()))
|
||||||
{
|
{
|
||||||
/* FIXME: Child in strange state now */
|
/* FIXME: Child in strange state now */
|
||||||
CloseHandle (pi.hProcess);
|
CloseHandle (pi.hProcess);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user