[Win32utils-devel] Question on CreateProcess and handle inheritance

Daniel Berger djberg96 at gmail.com
Wed Sep 2 06:55:39 EDT 2009


Hi,

I just wanted to make sure that I'm not confused by Michael Buselli's
comment and patch. As far as I can tell, if you set the bInheritHandle
in the SECURITY_ATTRIBUTES structure that's passed to CreateProcess to
true, it's the same as calling SetHandleInformation(handle,
HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) after the fact.

CreateProcess:

lpProcessAttributes [in, optional]

    A pointer to a SECURITY_ATTRIBUTES structure that determines
whether the returned handle to the new process object can be inherited
by child processes. If lpProcessAttributes is NULL, the handle cannot
be inherited.

SetHandleInformation:

HANDLE_FLAG_INHERIT

   If this flag is set, a child process created with the
bInheritHandles parameter of CreateProcess set to TRUE will inherit
the object handle.

Or is this a case of "can" (i.e. it's possible for the child to
inherit the handle) vs "will" (i.e. the child process will definitely
inherit the handle)?

Regards,

Dan


More information about the win32utils-devel mailing list