Browse - Programming Tips - How can I set whether a file handle is inherited by a child process?

Date: 2010may10
OS: Windows
Language: C/C++
Keywords: inherit, inherits

Q.  How can I set whether a file handle is inherited by a child process?

A.  Use this function:

BOOL SetInherit(HANDLE h, const BOOL bInherit) { return SetHandleInformation(h, HANDLE_FLAG_INHERIT, bInherit ? HANDLE_FLAG_INHERIT : 0); }