posix_spawn facility

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Apr 20 14:40:52 GMT 2023


On Apr 20 16:21, Corinna Vinschen via Cygwin wrote:
> On Apr 20 12:18, Bruno Haible via Cygwin wrote:
> >      The "inheritable handles" is a data structure that allows for the
> >      arbitrary reshuffling of file descriptors required by posix_spawn
> >      (the addopen, adddup2, addclose actions), i.e. which does the book-
> >      keeping which HANDLE must in the end be open in the parent and which
> >      must in the end be open in the child, and at which position.
> 
> Hmm.  Your code uses lpReserved2 for that, but the functionality is
> one implemented in MSVCRT.  For obvious reasons, Cygwin executables
> are not linked against msvcrt.dll and we're using lpReserved2 for our
> own purposes.

Oh, btw., did you know that there's a newer mechanism for defining
specific inheritable handles to CreateProcess, which is implemented
in kernel32.dll, so it does not depend on MSVCRT?

There's a STARTUPINFOEX structure which allows to specify the 
additional handles.  See

https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-startupinfoexa

and the PROC_THREAD_ATTRIBUTE_HANDLE_LIST argument described in

https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute


Corinna


More information about the Cygwin mailing list