* dtable.cc (set_std_handle): Use std_consts array to control SetStdHandle

settings.
(dtable::fixup_after_fork): Ditto.
* exceptions.cc (set_sig_errno): Remove some debugging output.
* path.cc (path_conv::check): Don't OR need_directory with flags sent to
symlink_info::check.
(symlink_info::check): Use PATH_ALL_EXEC to determine when a file is
executable.
* path.h (path_types): Add PATH_ALL_EXEC.
(isexec): Use PATH_ALL_EXEC so that cygexec types will be considered
executable.
* pinfo.h (_pinfo): Add a process handle that is kept open throughout the life
of a cygwin pid.
* sigproc.cc (proc_exists): Remove hopefully obsolete stuff.
(proc_subproc): Set up process handle that is kept open throughout the life of
a cygwin pid.  Reorganize PROC_WAIT stuff to use common code.
(proc_terminate): Close pid lifetime process handle.
(checkstate): Cleanup.
(stopped_or_terminated): Move zombie cleanup.
(remove_zombie): To here.
* spawn.cc (spawn_guts): Reorganize reparenting code for 1247th time.
This commit is contained in:
Christopher Faylor
2000-10-09 02:53:44 +00:00
parent 65bb926f51
commit 164a681ca5
9 changed files with 138 additions and 132 deletions

View File

@ -687,14 +687,11 @@ skip_arg_parsing:
/* We print the original program name here so the user can see that too. */
syscall_printf ("%d = spawn_guts (%s, %.132s)",
rc ? cygpid : (unsigned int) -1,
prog_arg, one_line.buf);
rc ? cygpid : (unsigned int) -1, prog_arg, one_line.buf);
MALLOC_CHECK;
/* Name the handle similarly to proc_subproc. */
ProtectHandle1 (pi.hProcess, childhProc);
ProtectHandle (pi.hThread);
MALLOC_CHECK;
if (mode == _P_OVERLAY)
{
@ -785,20 +782,16 @@ skip_arg_parsing:
{
case WAIT_OBJECT_0:
sigproc_printf ("subprocess exited");
if (!GetExitCodeProcess (pi.hProcess, &res))
res = 1;
DWORD exitcode;
if (!GetExitCodeProcess (pi.hProcess, &exitcode))
exitcode = 1;
res |= exitcode;
exited = TRUE;
if (nwait <= 2 || mode != _P_OVERLAY)
if (nwait <= 2 || (res & EXIT_REPARENTING) || (mode != _P_OVERLAY && mode != _P_VFORK))
/* nothing to do */;
else if (WaitForSingleObject (spr, 1) == WAIT_OBJECT_0)
goto reparent;
else if (!(res & EXIT_REPARENTING))
{
MALLOC_CHECK;
close_all_files ();
MALLOC_CHECK;
}
break;
case WAIT_OBJECT_0 + 1:
sigproc_printf ("signal arrived");
@ -809,7 +802,6 @@ skip_arg_parsing:
{
reparent:
res |= EXIT_REPARENTING;
close_all_files ();
if (!parent_alive)
{
nwait = 1;
@ -848,33 +840,37 @@ skip_arg_parsing:
/* nothing */;
else
{
int rc;
HANDLE hP = OpenProcess (PROCESS_ALL_ACCESS, FALSE,
parent->dwProcessId);
sigproc_printf ("parent handle %p, pid %d", hP, parent->dwProcessId);
if (hP == NULL && GetLastError () == ERROR_INVALID_PARAMETER)
int rc = 0;
HANDLE oldh = myself->hProcess;
HANDLE h = OpenProcess (PROCESS_ALL_ACCESS, FALSE,
parent->dwProcessId);
sigproc_printf ("parent handle %p, pid %d", h, parent->dwProcessId);
if (h == NULL && GetLastError () == ERROR_INVALID_PARAMETER)
rc = 1;
else if (hP)
else if (h)
{
ProtectHandle (hP);
rc = DuplicateHandle (hMainProc, pi.hProcess, hP,
&myself->hProcess, 0, FALSE,
ProtectHandle (h);
rc = DuplicateHandle (hMainProc, pi.hProcess,
h, &myself->hProcess, 0, FALSE,
DUPLICATE_SAME_ACCESS);
sigproc_printf ("Dup hP %d", rc);
ForceCloseHandle (hP);
sigproc_printf ("%d = DuplicateHandle, oldh %p, newh %p",
rc, oldh, myself->hProcess);
ForceCloseHandle (h);
}
if (!res)
if (!rc)
{
system_printf ("Reparent failed, parent handle %p, %E", hP);
system_printf ("Reparent failed, parent handle %p, %E", h);
system_printf ("my dwProcessId %d, myself->dwProcessId %d",
GetCurrentProcessId(), myself->dwProcessId);
system_printf ("myself->process_state %x",
myself->process_state);
system_printf ("myself->hProcess %x", myself->hProcess);
system_printf ("old hProcess %p, hProcess %p", oldh, myself->hProcess);
}
}
ForceCloseHandle1 (hExeced, childhProc);
hExeced = INVALID_HANDLE_VALUE;
if (hExeced)
{
ForceCloseHandle1 (hExeced, childhProc);
hExeced = INVALID_HANDLE_VALUE;
close_all_files ();
}
}
else if (exited)
{