Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2128154ybk; Mon, 11 May 2020 12:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEmQFT1Ktf3DmnYfG7LnAfXYbTbDP0oGf+gK9xLYEazJjQVw/gnVYqpcskmOrVzugr2KxN X-Received: by 2002:a17:906:7da:: with SMTP id m26mr6318264ejc.342.1589225786162; Mon, 11 May 2020 12:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589225786; cv=none; d=google.com; s=arc-20160816; b=izAXgOnjnRTld7NG3veR6pTTrhGradSB2p8iKoVYIdWDLAj94WgZquExz0KeR0HFxW 9Kxk0VxZOTbtpRRKJtULPZE0Lp1N+EgANaUBEz43kUlzDTZzCtSnmBoPC05wncR58xzi taBbK3wS4otsM1bMC51wP4x31KidD6b7jVaNNSILd0O5bqGHn6JTP4I5nfz60tZNzUWN qosXzXCFxqvAnzIDnsiEpbKbq0bbp3gxJyXt+e/C+li7UMalotQmkdRtvB0tOiIYoQsN E6Le4FKW28l415evKwzT3E0wmk9ZGj+6HFSanBtzC3A/Ac8l0QvA9l3vQEQ1dPND/w2K vnrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PdupfeR3R25/tcJ9rHIR0mur+MFPzqZKr63niiEJHBQ=; b=kTQUTvjOXtjzJSVrx7Mnru0VnkfurwSdGkVebfu0qlYC18HCIRd6SAkTHsgKsyz4Fg B55ZRYeYuMKqvcmDUIGr/Bjj0jqhkCdKUjeW1COnB7lKV+rikFUmmhMIXmpF/f3jAlfw F5pjtqWEA+CR9G/qcm4kH8FdQyWoBn/elNYxyoMKdkhQuEmDHvcfMBJIgF5T8hQnb164 O9YJJ3mxituGhTBa3u8HlCHLtpox5+bnzIHK1XRsLGahwIQUgk0DNxcxzzXJ6eSTx0E6 bYYhxHXCHB8EsXmqDEGDhQ1rRqG3WICZci+m5Ky/qw7VhqM5NtCj7Tbcnyk4NUbAdnlq IHeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HYP9BaJo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j93si3207672edd.447.2020.05.11.12.36.02; Mon, 11 May 2020 12:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HYP9BaJo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731456AbgEKTeU (ORCPT + 99 others); Mon, 11 May 2020 15:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729453AbgEKTeU (ORCPT ); Mon, 11 May 2020 15:34:20 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48967C061A0C for ; Mon, 11 May 2020 12:34:18 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id x73so8543481lfa.2 for ; Mon, 11 May 2020 12:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PdupfeR3R25/tcJ9rHIR0mur+MFPzqZKr63niiEJHBQ=; b=HYP9BaJozO8xTGyBSvFhj4mC89PmhhTI5wZVLw+Kgc3WQf9Nwye77lYnha2qpi0I2A VBcJc9qDjyWIVlWckj0XXhgIAjbs3ZHtkX61q7XTI8o0EQDcaDzqzRFwqWSDYsvwqGrT Ov6zjgkib3vCJNCHlIf43Lo2HfEgaZRPOj2s4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PdupfeR3R25/tcJ9rHIR0mur+MFPzqZKr63niiEJHBQ=; b=hmBh9cEPoSkSwvVj+Uhb0q5rGLzxb6CFQDzSJtMKELlqpFysNACBChz+CAvuljfDAX etzYx3bAbysqBzVWzLyz5z8TuejUCRthSfcQDrs1pPm3hyOH0cDrAlWyMQl2mDD/tOZx DCj7kK6y62H/sxCWto9z+ZqjeYTV1goNDJ3wR1ZMyUhgpwjjL9dhjq1YbmOMeNBz8pKi M5ILz9SOw/xL/QuZzki1A0/OCPdYYjUjHkCzhLM49ywpEc7QHhmyG7eGUz+cTLcDNUWg TOWV6LirmLYrgHwfdDSAYgI+cgb2Jgz0C9mAO/diYPuojfLL8dJirJHExXOCyT1mU914 hLYw== X-Gm-Message-State: AOAM530HDtvx0X4DTkWgo5r6tgNzGAOVFo8a5tdunN1oBLVhWEIl34Q9 6Y1cUz8W3Hf4cRzZW08ZVELoUMlBaO0= X-Received: by 2002:a05:6512:3ea:: with SMTP id n10mr12163041lfq.127.1589225656331; Mon, 11 May 2020 12:34:16 -0700 (PDT) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com. [209.85.167.44]) by smtp.gmail.com with ESMTPSA id j21sm10067193lja.2.2020.05.11.12.34.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 May 2020 12:34:15 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id b26so8540405lfa.5 for ; Mon, 11 May 2020 12:34:15 -0700 (PDT) X-Received: by 2002:a19:4816:: with SMTP id v22mr1923457lfa.30.1589225654675; Mon, 11 May 2020 12:34:14 -0700 (PDT) MIME-Version: 1.0 References: <8320f29ca61146fc985083621685ac95@AcuMS.aculab.com> <0ff4860b4202a6ef3bb3b29912d083d471e1cc1d.camel@gnu.org> In-Reply-To: <0ff4860b4202a6ef3bb3b29912d083d471e1cc1d.camel@gnu.org> From: Linus Torvalds Date: Mon, 11 May 2020 12:33:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: I disabled more compiler warnings.. To: Paul Smith Cc: David Laight , Arnd Bergmann , Masahiro Yamada , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 10:59 AM Paul Smith wrote: > > As with all single-threaded applications, though, the problem is the > difficulty (in a portable way) of handling both signals and wait*(2) > reliably... I do wonder if GNU make isn't making it worse for itself by blocking SIGCHLD. I wonder if you could just have three different file descriptors: - the "current token file descriptor" - a /dev/null file descriptor - the jobserver pipe file descriptor. This is left blocking. and then make the rule be that - the SIGCHLD handler just does dup2(nullfd, jobserverfd); This guarantees that any read() that was interrupted by a SIGCHLD will now reliably return immediately. But it also guarantees that if we raced, and the SIGCHLD happened just *before* we did the read(), the read() will also exit immediately. - the waiting code does check_child_status(); for (;;) { ret = read(jobserverfd, buffer, 1); if (ret == 1) { .. we got the token successfully, do whatever .. return; } /* The read might fail because of SIGCHLD - either we got interrupted, or the fd was replaced with /dev/null */ /* First, re-instate the pipe binding */ dup2(pipefd, jobserverfd); /* Then do the child status stuff again */ check_child_status(); /* Ok, we can restart, there's no races with SIGCHLD */ } which fundamentally doesn't have any races. Look, ma, no need for nonblocking reads, or pselect(). I don't know. Maybe I missed something. Linus