Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp796665ybn; Wed, 25 Sep 2019 07:52:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw6Ha/ynf9OlMxZgi1NB0i8qVNjUutceuFexvgwuB8FgpGDJI++T2I1QdE5X8n5PRz7y6+ X-Received: by 2002:a17:906:1ed1:: with SMTP id m17mr4427633ejj.82.1569423162327; Wed, 25 Sep 2019 07:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569423162; cv=none; d=google.com; s=arc-20160816; b=nxC2LcUUHi5sf5t2bgAI/oPGA4G4xYJx3Y1ycS+Re0L3r7P07Qn8XTtb0syBVR+zyW 7tcQiW1IWBnNYG+D9WtV10QdlSEp+Ty0xOh2fWebrv4la1DxxAeuNdvorLWcN3yKRHz7 cwQ6AV4A0lHA4BOYkqYtVhBhASns4YqBpQjgZrSZngU1kyz5PzqeY5gOb4MWAbAELJxl MtI8eeLzaKL0IwGLMUYnxS1KZC7q/wzbuGsQkYPVE065xhzuqO3EoL60wOpGW1KHt3CS SVHh6cDEU7TPjwbwV9d4EmPoF7IvjPL0LPri0lBq7aaL8bKYAlmbWj3K1tiWl+Kxd+4v BeNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MXXkt5zOaex7+OIP3HvG8H+z1oY3UulNO78FRJfzvYk=; b=kDFHbH10xmT57awcS/q1+ikbLZ01p9LOvUtBKl92yKeJfxQhX0hUaJsf1iE+D1hvyH sscU5ksbZZjF2w1hmJE1Tu8bMJoChuaexXyysbeayz/mH5D8izjYWQsE9rrcRKMOUm3q RBL56e4jGf86IVnyZhrlkHo3mbQUwJHTQA7i+1adzsIoxjNKCeoHIRKQwiqyY8+VZDO8 lH///fYbpIeCA2SbS3HUxffox5Stxml0U1vw/WhxhZ3zL/z46vl3yO0tEBO5GVZtrPbh kjq8Tg+RAm4bY/spHJhEpvO9Jxz+tURB92NN2sTgBHYsttap8KwHiWVonlPWqE/bN1Cz xuWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si2609252ejj.119.2019.09.25.07.52.16; Wed, 25 Sep 2019 07:52:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440064AbfIWOrk (ORCPT + 99 others); Mon, 23 Sep 2019 10:47:40 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42280 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438206AbfIWOrj (ORCPT ); Mon, 23 Sep 2019 10:47:39 -0400 Received: from [172.58.27.190] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iCPcd-000393-Is; Mon, 23 Sep 2019 14:47:28 +0000 Date: Mon, 23 Sep 2019 16:47:13 +0200 From: Christian Brauner To: Florian Weimer Cc: "Michael Kerrisk (man-pages)" , Christian Brauner , Jann Horn , Daniel Colascione , "Eric W. Biederman" , Joel Fernandes , Linux API , lkml , linux-man , Oleg Nesterov Subject: Re: For review: pidfd_open(2) manual page Message-ID: <20190923144711.ssbrg6bdquhewo7q@wittgenstein> References: <90399dee-53d8-a82c-3871-9ec8f94601ce@gmail.com> <87tv939td6.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87tv939td6.fsf@mid.deneb.enyo.de> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 23, 2019 at 12:53:09PM +0200, Florian Weimer wrote: > * Michael Kerrisk: > > > SYNOPSIS > > int pidfd_open(pid_t pid, unsigned int flags); > > Should this mention for pid_t? > > > ERRORS > > EINVAL flags is not 0. > > > > EINVAL pid is not valid. > > > > ESRCH The process specified by pid does not exist. > > Presumably, EMFILE and ENFILE are also possible errors, and so is > ENOMEM. So, error codes that could surface are: EMFILE: too many open files ENODEV: the anon inode filesystem is not available in this kernel (unlikely) ENOMEM: not enough memory (to allocate the backing struct file) ENFILE: you're over the max_files limit which can be set through proc I think that should be it. > > > A PID file descriptor can be monitored using poll(2), select(2), > > and epoll(7). When the process that it refers to terminates, the > > file descriptor indicates as readable. Note, however, that in the > > current implementation, nothing can be read from the file descrip‐ > > tor. > > “is indicated as readable” or “becomes readable”? Will reading block? > > > The pidfd_open() system call is the preferred way of obtaining a > > PID file descriptor. The alternative is to obtain a file descrip‐ > > tor by opening a /proc/[pid] directory. However, the latter tech‐ > > nique is possible only if the proc(5) file system is mounted; fur‐ > > thermore, the file descriptor obtained in this way is not pol‐ > > lable. > > One question is whether the glibc wrapper should fall back back to the > /proc subdirectory if it is not available. Probably not. No, that would not be transparent to userspace. Especially because both fds differ in what can be done with them. > > > static > > int pidfd_open(pid_t pid, unsigned int flags) > > { > > return syscall(__NR_pidfd_open, pid, flags); > > } > > Please call this function something else (not pidfd_open), so that the > example continues to work if glibc provides the system call wrapper. Agreed!