From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id a145b7eb for ; Fri, 12 Apr 2019 00:18:46 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 3677D9509B; Fri, 12 Apr 2019 10:18:45 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 3103995078; Fri, 12 Apr 2019 10:18:30 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 94E5095078; Fri, 12 Apr 2019 10:18:28 +1000 (AEST) X-Greylist: delayed 388 seconds by postgrey-1.36 at minnie.tuhs.org; Fri, 12 Apr 2019 10:18:28 AEST Received: from bugle.employees.org (accordion.employees.org [198.137.202.74]) by minnie.tuhs.org (Postfix) with ESMTPS id 43DDC95077 for ; Fri, 12 Apr 2019 10:18:28 +1000 (AEST) Received: by bugle.employees.org (Postfix, from userid 1736) id E7166FECBCD8; Fri, 12 Apr 2019 00:12:10 +0000 (UTC) Date: Fri, 12 Apr 2019 01:12:10 +0100 From: Derek Fawcus To: tuhs@tuhs.org Message-ID: <20190412001210.GA31597@bugle.employees.org> References: <7A06D817-72BD-47CB-BEE5-25755B4C3ABF@eschatologist.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7A06D817-72BD-47CB-BEE5-25755B4C3ABF@eschatologist.net> User-Agent: Mutt/1.11.4 (2019-03-13) Subject: Re: [TUHS] "Fork considered harmful" X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On Thu, Apr 11, 2019 at 04:37:52PM -0700, Chris Hanson wrote: > On Apr 10, 2019, at 4:06 PM, Richard Salz wrote: > > Any view on this? https://www.microsoft.com/en-us/research/publication/a-fork-in-the-road/ > Quite correct in my experience. > > The posix_spawn() API isn’t a panacea but (especially with a few *_np extensions) it’s much saner for large real-world applications that run a ton of subprocesses. I work on a large IDE which invokes compilers and such, and it makes a huge difference. What I ended up doing for children of GUI apps (on OSX) is to fork very early on before the GUI starts, or the process becomes multi-thread. Then that child does all of the real spawning, using fd passing and messages over a pipe (actually a unix domain socket) to drive it, so usually no need for _np stuff. There for cases where posix_spawn() is viable, as I recall it was faster than fork+exec. DF