Glenn wrote:
> > > 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
> > ...
> Excellent (very technical) article on the subject:
> 
> Programmatically controlling which handles are inherited by new processes in 
> Win32
> https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873

It's nice to see an example for PROC_THREAD_ATTRIBUTE_HANDLE_LIST.

But the article exaggerates a problem:
  "But all this inheritability fiddling still had a fatal flaw: What
   if two threads within the same process both call Create­Process but
   disagree on which handles they want to be inherited?"
The answer, overlooked in the article, is to use DuplicateHandle
and set the inheritability of the duplicate to true. Concurrently
running posix_spawn invocations in other threads will not see the
duplicates, since they only see HANDLEs that are assigned to file
descriptors, not HANDLEs that merely reside in some data structure
in memory.

Bruno




-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to