X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8168385702C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1682019136; bh=mHiHeUhgzC1CHlJ9eVA1wjnBCly4NN6WQcu6L9qef2c=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Sh8UvxjSVEuxc+OfeCv1q5RCQDRNXVU7wiXOXkcPZdkM7o/3/VybS3cufM+4tl0KW 9B3HuveMw/pWzgUQPgBowRvbSF0z8yLNvffo9Tp/MDfG723XeRdsEwRzl8dccNVctB bzwMUu+Iy/RmGjXcYTpg/uHfbj8LBPHbW34wCObY= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E9273858C83 ARC-Seal: i=1; a=rsa-sha256; t=1682019098; cv=none; d=strato.com; s=strato-dkim-0002; b=SPTVZBcAVxL89OuaUlZFvXeLni1D8Rosrrj9TCHRamdtFaGxn1eOpYFgFB17SffKTM QEu3nOlft37hZHazl/KsddxU+xtk7pZrIlghCE2EMwq8di5FI10CpNqrYSuE6xmeRjNM /QsXsix71IjNqqfZZT5+/FsLSP9pQfqMsIApTGkf+Gvf48r/Q7wb1KIWNIHKhHBxk1cF XvdzNcthEs/NQ6b94wNH0Tx6rm2VlnQkeql8WSlaJ4U4l5NbIpGhu9u2gJozikSa4A+u DLV1epicc0SjyJJLWpn/1XwNt7t/wPJKExp8ry4jsoYQn7r10KdV1/tASB5BFuxQIlRM gRXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1682019098; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=R4dtXiZ1zOpmv2Sxj7U2EmbD7oZFJXlBI0GkAvuKOBU=; b=hhEf+ChZONonZ068UVig5TSdxa4l/uXsmFzxYaLt0v4vRhEPH18aLoMKG7gFdGWDHz +d4kITDkEykdOf2qzWg8rUT3FgWwSkbHoe7vfTssKi9TgNZU+cqd4R/wAsV5o6BHOks1 FtGb8XrriAw7r7jaG6Dae5t0JKYWkNcVEewz0jHBcnuF0sGI28o6DgEbW1lMMyoKcz3R z7GeEfJFK11xdOQzmjujTJWecNaBWpC9KijKo/evrBiyhwmCut0CZ4tMpCDMgWi3yBrC dRVXNuFE4RDyUm7EtIG3gbc2ptgLWxEKy6VTFGDFi8bd+Tn/VGU8aShKoli5PI+NYl5i LWdQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPDj/1vgIuvkaOwJLsXaUZx50Vobw==" To: gs-cygwin DOT com AT gluelogic DOT com Cc: cygwin AT cygwin DOT com Subject: Re: posix_spawn facility Date: Thu, 20 Apr 2023 21:31:38 +0200 Message-ID: <2162092.C4sosBPzcN@nimes> In-Reply-To: References: <1752276 DOT 7aRn1RRit1 AT nimes> <4892432 DOT 0VBMTVartN AT nimes> MIME-Version: 1.0 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Bruno Haible via Cygwin Reply-To: Bruno Haible Content-Type: text/plain; charset="iso-8859-1" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 33KJWhU8016455 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