Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6194701imd; Wed, 31 Oct 2018 08:10:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5eiCXFwfnWHmUZLO/gHG2Pu/i4lV3c7OA/Tl4g29OJT1ctCXZMigoUTg7U0fgYdm60kLlmz X-Received: by 2002:a63:ed42:: with SMTP id m2mr3572750pgk.147.1540998641196; Wed, 31 Oct 2018 08:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540998641; cv=none; d=google.com; s=arc-20160816; b=eEGov4WSmvwCy60hYGNV7zI/SA8F7l3OsbdbraYc92W3cLlJIfqXQSqQSgzVdeI6X4 VjCEpwCwMWxp2Jwtbzl4nr4C1/3hnpHc4XIy5UpPme8+VtXbee+tBw36IgTqMaBoggr5 D33IUzgazlh5pEt9EmHZH87PrOsi96eW91gmMGIUklJ/+N5utIPWTCxC998tEcN5zd9x fdIHxGAk8zESJZsElLMPYYfAZ1kvQQFLR8CuhYsUS6Nbu1sJr0yTkyIF1EnEs6QoAzV2 jrs2JUUC9QJV4oA2baM/ZpnLYNMikoyntS3Y3yXeeNiVCuP4P73P39qJStxllbEbhXw/ acrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=MdeA04nU+MLEKdLZHJb7KdahAUeTZ8VVAY1vZvjqjuU=; b=BjvYNjCsG2u+kepvPRRYqLeI3jZhHElP2Z9Nv1Rv6UL2O61Hmeyalkd6BpQKqPBCVQ 6L6eKsfw0SDdQgI2Z7MO6CMTGoIss0pPwRSw6ffoXne3P5aRJ0Qxwypnh7hiX76UzHVg 5CrlJwn5XT/2Klmnj07MkGuRsyIeFg3SJoJbxhCtF8V3zpzUTXKxfJUOBibQY0keJ2X9 W9hdJ+SeDP9CRqRhome/yUhYKco6H86p5C/Ep2izZcqhBovehGDpR+pL0gdto2SnUYmV iFJb/WoUfLUByw2x0Jh5UTcyfVehn1nXw9JIrRXljtbzb/GD6pr7pXnIyIvanU+8ktF1 aQHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UGakynDl; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si10453223plr.40.2018.10.31.08.10.15; Wed, 31 Oct 2018 08:10:41 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=UGakynDl; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729399AbeKAAFI (ORCPT + 99 others); Wed, 31 Oct 2018 20:05:08 -0400 Received: from mail-it1-f201.google.com ([209.85.166.201]:42826 "EHLO mail-it1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728964AbeKAAFH (ORCPT ); Wed, 31 Oct 2018 20:05:07 -0400 Received: by mail-it1-f201.google.com with SMTP id v125-v6so17416712ita.7 for ; Wed, 31 Oct 2018 08:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=MdeA04nU+MLEKdLZHJb7KdahAUeTZ8VVAY1vZvjqjuU=; b=UGakynDllCqQPpustjzPu9CoqcvyfyKsrJKhS1bW0bo1OKHCPW4q8leNP00m6RN/57 FSQoH9DtcASyC0uoBpGG/wQMR+5nupBbKkNrXRF2pXJHcTlpL869kr+0NhDXCK6V7yeT 5rRPl50eI+uPOB4X9ZEWbVMWsDFy5wuF+Pf0cx4WLUlrNa0BPkv29Pdt/H86WTHP+8n5 6oyAE3W87U02VkpK64D3tCewu/UlrYCcMIZZc9486HOEOn7BwXIH+RND9lrnTAnB2+IQ BeFnS93X1At5Ct006iLbazOTOotHIiz4LeQZkghQIuCJZYq88NA+drQIfN9iR4bKIqUt F3Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=MdeA04nU+MLEKdLZHJb7KdahAUeTZ8VVAY1vZvjqjuU=; b=ie8KBXVw1FQax+huMD+8hfbf0rDl4ELOGbyFWu4D7iv3+YfFdGr3b/Oglix/FzGxHU oMslYanCE863WTt8sk0rDEha/2M9Hk7Mlsf9lIvdgN8Kb2+4veWPOqbLnjNhvE+mWnOy fzh0yaAqkh2p+sIIC+Txe5IB52LV6DGT/zVDTANCLE/fGrHseE3pgIO1Y2Hlxsv9/Ag5 Bwgyz7eHWgykjNYs2x7qV2Ele4xd0/4G/A9iNL5epBu1BYcGqRgyfXXeCTgnQvpbzauU 8OLPB0Iw3jrRVTzSydhf6cSa8is8CHB+foM3uFkOuHIRPq0f+JUOmJdI0NHS1xwxgQYL 1x/w== X-Gm-Message-State: AGRZ1gLSKWg22dZNPqxi9OhA48YC2HSIedQlGW5oquH0DYgtxXoNCVaZ 3Yb8EeySI9BpDBuR2I1HYtUkofOLBgMcqs4Y6ua/hNL1zv15xhYPNTfUsB2dl5oJopTNr1fO814 2bgbAoYFASpZHulZn7d1z5aJ8bWsIzT1LDOcGCOait143shhu3nFm96IlvUj2ui182F/j7g== X-Received: by 2002:a24:1cd2:: with SMTP id c201-v6mr1953892itc.35.1540998403369; Wed, 31 Oct 2018 08:06:43 -0700 (PDT) Date: Wed, 31 Oct 2018 15:06:22 +0000 Message-Id: <20181031150625.147369-1-dancol@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.1.568.g152ad8e336-goog Subject: [PATCH] Document /proc/pid PID reuse behavior From: Daniel Colascione To: linux-kernel@vger.kernel.org Cc: timmurray@google.com, joelaf@google.com, surenb@google.com, Daniel Colascione , Jonathan Corbet , Andrew Morton , Roman Gushchin , Mike Rapoport , Vlastimil Babka , "Dennis Zhou (Facebook)" , "Kirill A. Shutemov" , Prashant Dhamdhere , "open list:DOCUMENTATION" 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 State explicitly that holding a /proc/pid file descriptor open does not reserve the PID. Also note that in the event of PID reuse, these open file descriptors refer to the old, now-dead process, and not the new one that happens to be named the same numeric PID. --- Documentation/filesystems/proc.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 12a5e6e693b6..567f66a8a23c 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -214,6 +214,14 @@ asynchronous manner and the value may not be very precise. To see a precise snapshot of a moment, you can see /proc//smaps file and scan page table. It's slow but very precise. +Note that an open a file descriptor to /proc/ or to any of its +contained files or subdirectories does not prevent being reused +for some other process in the event that exits. Operations on +open /proc/ file descriptors corresponding to dead processes +never act on any new process that the kernel may, through chance, have +also assigned the process ID . Instead, operations on these FDs +usually fail with ESRCH. + Table 1-2: Contents of the status files (as of 4.8) .............................................................................. Field Content -- 2.19.1.568.g152ad8e336-goog