From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752122AbbCNW0T (ORCPT ); Sat, 14 Mar 2015 18:26:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:60208 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbbCNW0R (ORCPT ); Sat, 14 Mar 2015 18:26:17 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,402,1422950400"; d="scan'208";a="692213122" From: Thiago Macieira To: Josh Triplett Cc: Oleg Nesterov , Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Kees Cook , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 6/6] clone4: Introduce new CLONE_FD flag to get task exit notification via fd Date: Sat, 14 Mar 2015 15:26:05 -0700 Message-ID: <2340007.MPGOIEd6Rm@tjmaciei-mobl4> Organization: Intel Corporation User-Agent: KMail/4.14.5 (Linux/3.11.10-25-desktop; KDE/4.14.5; x86_64; ; ) In-Reply-To: <20150314220307.GI22130@thin> References: <20150314185424.GA6813@redhat.com> <20150314220307.GI22130@thin> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday 14 March 2015 15:03:08 Josh Triplett wrote: > I had to think about this for a while, but I think it makes sense now. > wait should *not* ever return the PID of an autoreaped process, because > that would introduce a race condition (the caller cannot safely do > *anything* with the PID of an autoreaped process, since by the time it > does, the process may be gone and the PID may be reused). However, that > doesn't mean wait cannot block on the process, and then subsequently > wake up and return -ECHILD (or keep waiting on some other child process > if there is one). That's apparently the semantic used with SA_NOCLDWAIT > or if you have SIGCHLD set to SIG_IGN, and matching that seems > appropriate. > > Thiago, could your QProcess implementation handle that modified autoreap > semantic? The downside there is that if your calling process has a > process-wide loop that waits for all processes (and explicitly passes > the Linux-specific __WCLONE or __WALL flag, since your processes > launched with a 0 signal would count as "clone" children), they'd get > back the processes you launch, too. (That would happen with your > userspace-emulated version too for calls *without* __WCLONE or __WALL.) > You'd still get the exit status you need via the clonefd, without a > race, and you wouldn't need to touch process-wide signal handling, so I > think this should still work and avoid any races. I don't see why QProcess would have a problem. We don't have such a process- wide wait loop with __WCLONE or __WALL and I can't think of any reason why someone would do that and still expect NPTL to work. Or, put another way, if they are using clone/clone4 directly and bypassing NPTL, they're probably in a very specialised process that has no business running QProcess in the first place. I wouldn't be too worried. Inside glibc itself, __WCLONE is used only in unit tests and __WALL is used in a loop in elf/pldd.c, which is an independent application. Bionic has __WCLONE in tests only too. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center