From owner-svn-src-all@freebsd.org Sat Nov 21 02:29:39 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F13CA341C2; Sat, 21 Nov 2015 02:29:39 +0000 (UTC) (envelope-from yelliott@gmail.com) Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com [IPv6:2607:f8b0:4003:c06::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3C5141FCF; Sat, 21 Nov 2015 02:29:39 +0000 (UTC) (envelope-from yelliott@gmail.com) Received: by oiww189 with SMTP id w189so75292610oiw.3; Fri, 20 Nov 2015 18:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=fncdJTmPOig3ETg9lqzDnQpV6V2Xd92QQHfoY0D1QZQ=; b=wS0/r7FDqYe6ZGKTQmrH16ciDD9qIrTPIER67gFm3QqXFEm1rVNrJJK0AReQreOv9W bbi3J95I9iRY8/0LIa9QJLAUGrqo3qRMD/hbmbHByjD2DAAr78nQNMvUg3kBCWFVikqv jliRGLIA65Gl60aEkdQRhMAZq6fHSoXyERQJdMccLSRWVha5qW4G2DpniSdDlDCvv67h ptYQLuSEGbYqGpv9+LFPP8r2DDYoOHO44KgYsK6oRKqsm4C1Fg6Rpy0ldQ3fzTvgKUT2 CEmAWS5UaL4KzeAJtW0xmj9T62x1ADh8nysxKQinDcja8khBSTRED4Wn5qjToFTvWKZN wxFQ== MIME-Version: 1.0 X-Received: by 10.202.80.204 with SMTP id e195mr10670978oib.75.1448072978638; Fri, 20 Nov 2015 18:29:38 -0800 (PST) Received: by 10.202.205.15 with HTTP; Fri, 20 Nov 2015 18:29:38 -0800 (PST) In-Reply-To: <564FB5F3.1080301@freebsd.org> References: <201511202236.tAKMaf06048447@repo.freebsd.org> <564FAAB0.6000600@freebsd.org> <28C3C55F-BF25-4DB2-AF05-B57F3F2CCAD5@panasas.com> <564FB5F3.1080301@freebsd.org> Date: Fri, 20 Nov 2015 21:29:38 -0500 Message-ID: Subject: Re: svn commit: r291114 - head/lib/libc/gen From: David Sanderson To: Andrey Chernov Cc: Ravi Pokala , Ravi Pokala , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Sanderson, David" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2015 02:29:39 -0000 On Fri, Nov 20, 2015 at 7:08 PM, Andrey Chernov wrote: > On 21.11.2015 2:57, Ravi Pokala wrote: > > There's two different things at play - userland resources and kernel > resources. Both "FILE *iop" and "struct pid *cur" are userland, while the > descriptors in "pdes" are kernel. We clean up the descriptors in "pdes" in > call cases, so we're not leaking kernel resources. You're right that "iop" > (and "cur", which you didn't mention) appear to be leaked in the child, in > that they're not explicitly cleaned up. But they get wiped away by the > _execve(), so it doesn't matter. > > See my next reply. I care not about userland resources, but about > fdopen() ability to set FD_CLOEXEC. Hi Andrey, I'll step into this discussion because Ravi submitted this change on my behalf. Thank you for pointing out the possibility of fdopen() setting FD_CLOEXEC on the parent's end of the pipe if the mode string contains an 'e'. This is indeed documented on popen(3). However, note that popen() uses pipe2(pdes, O_CLOEXEC) to create the pipe -- so both ends of the pipe start out with FD_CLOEXEC set. If the caller uses popen() with "re" or "we", the fdopen() code will simply set FD_CLOEXEC on the parent's end of the pipe _again_. So moving the fdopen() prior to the fork() doesn't have any net effect on the file descriptors the child process receives, even in the face of popen() with "re" or "we". Does this address your concerns? Thanks, David Sanderson