* DevNotes: Add entry cgf-000007.
* child_info.h (child_info_spawn::parent_winpid): Declare new field. (child_info_spawn::get_parent_handle): Declare new function. * dcrt0.cc (child_info_spawn::get_parent_handle): Define new function. (child_info_spawn::handle_spawn): Recreate parent handle if possible when dynamically loaded. Don't mess with parent handle if it's NULL. * spawn.cc (child_info_spawn::worker): Set parent_winpid appropriately.
This commit is contained in:
parent
77009cee1e
commit
3de7be4c1d
|
@ -1,3 +1,13 @@
|
||||||
|
2012-05-14 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
|
* DevNotes: Add entry cgf-000007.
|
||||||
|
* child_info.h (child_info_spawn::parent_winpid): Declare new field.
|
||||||
|
(child_info_spawn::get_parent_handle): Declare new function.
|
||||||
|
* dcrt0.cc (child_info_spawn::get_parent_handle): Define new function.
|
||||||
|
(child_info_spawn::handle_spawn): Recreate parent handle if possible
|
||||||
|
when dynamically loaded. Don't mess with parent handle if it's NULL.
|
||||||
|
* spawn.cc (child_info_spawn::worker): Set parent_winpid appropriately.
|
||||||
|
|
||||||
2012-05-12 Christopher Faylor <me.cygwin2012@cgf.cx>
|
2012-05-12 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
* DevNotes: Add entry cgf-000006.
|
* DevNotes: Add entry cgf-000006.
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
2012-05-14 cgf-000007
|
||||||
|
|
||||||
|
<1.7.16>
|
||||||
|
- Fix invocation of strace from a cygwin process. Fixes:
|
||||||
|
http://cygwin.com/ml/cygwin/2012-05/msg00292.html
|
||||||
|
</1.7.16>
|
||||||
|
|
||||||
|
The change in cgf-000004 introduced a problem for processes which load
|
||||||
|
cygwin1.dll dynamically. strace.exe is the most prominent example of
|
||||||
|
this.
|
||||||
|
|
||||||
|
Since the parent handle is now closed for "non-Cygwin" processes, when
|
||||||
|
strace.exe tried to dynamically load cygwin1.dll, the handle was invalid
|
||||||
|
and child_info_spawn::handle_spawn couldn't use retrieve information
|
||||||
|
from the parent. This eventually led to a strace_printf error due to an
|
||||||
|
attempt to dereference an unavailable cygheap. Probably have to fix
|
||||||
|
this someday. You shouldn't use the cygheap while attempting to print
|
||||||
|
an error about the inavailability of said cygheap.
|
||||||
|
|
||||||
|
This was fixed by saving the parent pid in child_info_spawn and calling
|
||||||
|
OpenProcess for the parent pid and using that handle iff a process is
|
||||||
|
dynamically loaded.
|
||||||
|
|
||||||
2012-05-12 cgf-000006
|
2012-05-12 cgf-000006
|
||||||
|
|
||||||
<1.7.16>
|
<1.7.16>
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
HANDLE subproc_ready; // used for synchronization with parent
|
HANDLE subproc_ready; // used for synchronization with parent
|
||||||
HANDLE user_h;
|
HANDLE user_h;
|
||||||
HANDLE parent;
|
HANDLE parent;
|
||||||
|
DWORD parent_winpid;
|
||||||
DWORD cygheap_reserve_sz;
|
DWORD cygheap_reserve_sz;
|
||||||
unsigned fhandler_union_cb;
|
unsigned fhandler_union_cb;
|
||||||
DWORD exit_code; // process exit code
|
DWORD exit_code; // process exit code
|
||||||
|
@ -175,6 +176,7 @@ public:
|
||||||
lock->release ();
|
lock->release ();
|
||||||
return !!hExeced;
|
return !!hExeced;
|
||||||
}
|
}
|
||||||
|
bool get_parent_handle ();
|
||||||
bool has_execed_cygwin () const { return iscygwin () && has_execed (); }
|
bool has_execed_cygwin () const { return iscygwin () && has_execed (); }
|
||||||
operator HANDLE& () {return hExeced;}
|
operator HANDLE& () {return hExeced;}
|
||||||
int worker (const char *, const char *const *, const char *const [], int,
|
int worker (const char *, const char *const *, const char *const [], int,
|
||||||
|
|
|
@ -625,13 +625,24 @@ child_info_fork::handle_fork ()
|
||||||
api_fatal ("recreate_mmaps_after_fork_failed");
|
api_fatal ("recreate_mmaps_after_fork_failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
child_info_spawn::get_parent_handle ()
|
||||||
|
{
|
||||||
|
parent = OpenProcess (PROCESS_VM_READ, false, parent_winpid);
|
||||||
|
moreinfo->myself_pinfo = NULL;
|
||||||
|
return !!parent;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
child_info_spawn::handle_spawn ()
|
child_info_spawn::handle_spawn ()
|
||||||
{
|
{
|
||||||
extern void fixup_lockf_after_exec ();
|
extern void fixup_lockf_after_exec ();
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
cygheap_fixup_in_child (true);
|
if (!dynamically_loaded || get_parent_handle ())
|
||||||
memory_init (false);
|
{
|
||||||
|
cygheap_fixup_in_child (true);
|
||||||
|
memory_init (false);
|
||||||
|
}
|
||||||
if (!moreinfo->myself_pinfo ||
|
if (!moreinfo->myself_pinfo ||
|
||||||
!DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo,
|
!DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo,
|
||||||
GetCurrentProcess (), &h, 0,
|
GetCurrentProcess (), &h, 0,
|
||||||
|
@ -669,7 +680,7 @@ child_info_spawn::handle_spawn ()
|
||||||
Otherwise, we no longer need this handle so close it.
|
Otherwise, we no longer need this handle so close it.
|
||||||
Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of
|
Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of
|
||||||
handles might get confused. */
|
handles might get confused. */
|
||||||
if (type != _CH_EXEC)
|
if (type != _CH_EXEC && child_proc_info->parent)
|
||||||
{
|
{
|
||||||
CloseHandle (child_proc_info->parent);
|
CloseHandle (child_proc_info->parent);
|
||||||
child_proc_info->parent = NULL;
|
child_proc_info->parent = NULL;
|
||||||
|
|
|
@ -12,3 +12,5 @@ fifo. Fixes: http://cygwin.com/ml/cygwin/2012-05/msg00253.html
|
||||||
- Fix hang when calling pthread_testcancel in a canceled thread.
|
- Fix hang when calling pthread_testcancel in a canceled thread.
|
||||||
Fixes some of: http://cygwin.com/ml/cygwin/2012-05/msg00186.html
|
Fixes some of: http://cygwin.com/ml/cygwin/2012-05/msg00186.html
|
||||||
|
|
||||||
|
- Fix invocation of strace from a cygwin process. Fixes:
|
||||||
|
http://cygwin.com/ml/cygwin/2012-05/msg00292.html
|
||||||
|
|
|
@ -614,6 +614,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
|
||||||
SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, 0);
|
SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, 0);
|
||||||
SetHandleInformation (parent, HANDLE_FLAG_INHERIT, 0);
|
SetHandleInformation (parent, HANDLE_FLAG_INHERIT, 0);
|
||||||
}
|
}
|
||||||
|
parent_winpid = GetCurrentProcessId ();
|
||||||
|
|
||||||
/* When ruid != euid we create the new process under the current original
|
/* When ruid != euid we create the new process under the current original
|
||||||
account and impersonate in child, this way maintaining the different
|
account and impersonate in child, this way maintaining the different
|
||||||
|
|
Loading…
Reference in New Issue