From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3223 invoked from network); 27 Jun 2022 14:29:28 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 27 Jun 2022 14:29:28 -0000 Received: (qmail 30202 invoked by uid 550); 27 Jun 2022 14:29:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 30167 invoked from network); 27 Jun 2022 14:29:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656340152; bh=RLrrTPBXIIa6F009/Ici6QQsrC5ZXUmbGOicOlv9yfc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=IRl7zdiYmRkuspIjKyaujDeflYovZo8MsTuS8AvdxhKXTXf3hzK3EGEv4iMrB8rqo VZpR2msF10QD2/ZEkhmjgKRSTKa+O6s3MbtMIG8Rc+T9g6R4EgxrR6fZ0WShcMlYrB 8fZ8V0mKP5ZfCILsb7zX51p/r0A/ewtsvd7M93Wg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Date: Mon, 27 Jun 2022 16:29:11 +0200 From: Markus Wichmann To: musl@lists.openwall.com Cc: Nick Peng Message-ID: <20220627142911.GC2408@voyager> References: <20220625125110.GV1320090@port70.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In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Quj2/kYS7Ntw6PxP9/6sQbE0hg6LKQRafXlzuSMT8k+xGf7U1EAqXpR9Q/tqp8An Av6XNMQDBudQYtJISYMHPJrF74VM8pIcHz5M9pY3Ci1/JKb/AU8A6f27DaJ2zjJ9nxiHYrf9D d2pX1qNtG5LlrbTxNf66Hhn0Uwffdb2Ap+UkeWklUE4OiKSqGnKbWGFbmcwhiDgLRtg3N+FwI mRgIfytwpoqPvEJVNlNXTW1MDeY53+Se6sVu5nvawn8Z8pdvvnrtpqjc4KTcsA7rLzjOWybOX L9oIdzGHefRdH5VvUnoNznSnKa+T2RC3dFITToHNf490vfjZD331JRWpVjWto1UqtATHIhw+L mZqF4FfhoNbP0Ic3Yw8/VJbwQaMbunB9YRosOUy0oSzdkYdrmkQKLU4Ow== Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] BUG: Calling readdir/dirfd after vfork will cause deadlock. On Mon, Jun 27, 2022 at 12:05:41PM +0800, Nick Peng wrote: > The feature I want to achieve is to close all file handles after fork to > avoid file handles being inherited to child processes. > The normal solution to that problem is FD_CLOEXEC. I have started just opening all FDs with FD_CLOEXEC set. If I want to bestow it upon a child process, I can always dup() it (which clears FD_CLOEXEC from the destination FD). > In order to avoid file handles inheriting from child processes, we > implemented a API like system,close all file handles after vfork. That wouldn't be conforming to the vfork() spec either, since close() is neither _exit() nor in the exec* family. > The component is based on glibc, currently this program runs for about 1= 0 > years without deadlock. > Recently, this component is used in musl-based embedded systems, and it > hangs often. > Congratulations, you found a way to make undefined behavior break your setup only a decade after its inception. Such is the nature of the beast. Sometimes it will work for you. Until something changes, that may be out of your control. Ciao, Markus