posix_spawn facility
Bruno Haible
bruno@clisp.org
Thu Apr 20 14:58:20 GMT 2023
Corinna Vinschen wrote:
> > 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
Indeed, this appears to be a more "official" way to pass handles for fd ≥ 3,
instead of lpReserved2 — albeit without associated 'flags'. Not sure how
O_APPEND is handled then... (Note: O_APPEND behaviour is tested by
gnulib/tests/test-posix_spawn-open2.c.)
I had seen this doc page, but thought it was irrelevant because the
title is about "thread attributes", not "process attributes"...
Bruno
More information about the Cygwin
mailing list