From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755840AbbCPWO3 (ORCPT ); Mon, 16 Mar 2015 18:14:29 -0400 Received: from mga11.intel.com ([192.55.52.93]:35367 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753151AbbCPWOX (ORCPT ); Mon, 16 Mar 2015 18:14:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,412,1422950400"; d="scan'208";a="680999997" From: Thiago Macieira To: Kees Cook Cc: Josh Triplett , Al Viro , Andrew Morton , Andy Lutomirski , Ingo Molnar , Oleg Nesterov , "Paul E. McKenney" , "H. Peter Anvin" , Rik van Riel , Thomas Gleixner , Michael Kerrisk , LKML , Linux API , "linux-fsdevel@vger.kernel.org" , "x86@kernel.org" Subject: Re: [PATCH v2 0/7] CLONE_FD: Task exit notification via file descriptor Date: Mon, 16 Mar 2015 15:14:14 -0700 Message-ID: <2381173.VxaIO6vGG3@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: References: 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 Monday 16 March 2015 14:44:20 Kees Cook wrote: > > O_CLOEXEC > > Set the close-on-exec flag on the new file > >descriptor. See the description of the O_CLOEXEC flag in open(2) for > >reasons why this may be useful. > > This begs the question: what happens when all CLONE_FD fds for a > process are closed? Will the parent get SIGCHLD instead, will it > auto-reap, or will it be un-wait-able (I assume not this...) Depends on CLONE_AUTOREAP. If it's on, then no one gets SIGCHLD, no one can wait() on it and the process autoreaps itself. If it's no active, then the old rules apply: parent gets SIGCHILD and can wait(). If the parent exited first, then the child gets reparented to init, which can do the wait(). A child without CLONE_AUTOREAP should be wait()able. If it gets wait()ed before the clonefd is read, the clonefd() will return a 0 read. If it gets read before wait, then wait() reaps another child or returns -ECHILD. That's no different than two threads doing simultaneous wait() on the same child. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center