Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6030858imd; Wed, 31 Oct 2018 05:56:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5eC/Nmy8qkwEGHz2eTO6CqQvt0X1TYPdwJqEFeSPe1/OCmw4lLasJTw5ymcQNEeOsZ3IxLs X-Received: by 2002:a63:5517:: with SMTP id j23-v6mr3023209pgb.208.1540990619284; Wed, 31 Oct 2018 05:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540990619; cv=none; d=google.com; s=arc-20160816; b=r0F6iQgO1KwR+rNThJs2vIu2zifnU40iGgFA469DuSQk8vQqlG3B/On1pn75ewNkWS 44ZUe6vH00okHBzDFL5Q2DCtQRdE7ZFKrAh0kpMrVaf8SshgYcoXkycEbp/v339UcsjZ Daq8hTmVtqGTc8XV876AG6WiLD/lJQ7vZrbgVP6mKsfoevMBcnDlv+RchbrCO/hKW7YV pAbDfdSC6qYlXCRZP5OMSygH6ELbVpqVtx8rjZvMopYcX1Z2rjwVyfxKgupcbRkhd6Pb t/tsDVvEB9vIQaMo34AiXFEAhVYy2eAwa/GXQiIdDZMXVgB7QxExoUsz43c4bmBLz11k OZxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=2748mQjQZ5HZ8OHwmIKNL4oZpWL6si+Toa6T7ktkpG8=; b=UWEetcTvA3tc80DrcZcY0dPC5mUzYT+VbHAqVKFxSgJiqbapObUCXqzYB/0yMeMi4d uw+lR0pdRu5OPeBJIc9sdyEgL4pkqrnKFybT5hdEue8ylIq5cRXaLtIL+7ehY2AGagCj H4mN/xJESbcJWgnMkiQWLbKPSLbmZq07mRE1IjB7JyqoBckULjCcacSJazctm7DnY42T T010H4RyF2xBMv0mxzwb1Gml+tU64uEZuYzsQ0qM2MafxnT7k5NSYCnqbG6LWa1vQ0x1 k9RD5HWzwqPPpzT5iuR6UeSqcC087XkzoXAfm2iXd+/4GIsXw71uRZWPSvjssFZ5YBGU nndw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZcZjX9Mq; 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 t11-v6si25454217plq.280.2018.10.31.05.56.43; Wed, 31 Oct 2018 05:56:59 -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=ZcZjX9Mq; 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 S1729195AbeJaVyJ (ORCPT + 99 others); Wed, 31 Oct 2018 17:54:09 -0400 Received: from mail-vk1-f195.google.com ([209.85.221.195]:44859 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728930AbeJaVyJ (ORCPT ); Wed, 31 Oct 2018 17:54:09 -0400 Received: by mail-vk1-f195.google.com with SMTP id h128so2390293vkg.11 for ; Wed, 31 Oct 2018 05:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2748mQjQZ5HZ8OHwmIKNL4oZpWL6si+Toa6T7ktkpG8=; b=ZcZjX9MqSMkHPNQEGkf/1r4cQ0yR4GD1WnR6odKOLR7Sezbz4u89T2YlojZmG6dU+4 XjxyOh5ZFv/Jc0BKLfPuCPfRy9AoTdDscd1k7zhqKDEFYx0nkt6yYwymjdpTTN9pRMsd w7fbJGUaHBBEwjbNfYWleIe/rSb0a/6kcORrrGVAeamcZXXLtf2y5xqlp4vcN4hVmUA/ OkcNUmo9iqHplwv+XkzriX3CMPp5doRDqjxZDDc53UF9PRU6Hsy1S1Gn0n0iw6xccF+8 Tpq0betEVhLaWbJ+BFFPIaQ8iQ8t4OM/BsPPqbLwq5xt0vFLuda0NVvHYl57MwnJFKM0 D86w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2748mQjQZ5HZ8OHwmIKNL4oZpWL6si+Toa6T7ktkpG8=; b=Tdtzp1Xguat1dKqMTA4c5i2DzzPNhKkRIkLENs5eYzytw96fi6dtmxWS/DJuoIS1x+ PyVVBJwVOfZINhOMq5zm4LSvPrLqdzMyHXAt3VlI9hi146o8cSlYE8RNNt5djUe2ArPR C1OZywLjEZRUSyb3mOsQ5XLM3yHoG49sfvRcoYlQcro3cdi8ZQuAlCIi182/hwsBfTzT zSxsF23MswCdlXDFSSpTzMrXWO5kjfTN4nHVGu9EzW7uIqLPZRZV1YwylE2+KLdyMOMI YifFj/sTP6vG7McjkOTEo75jV2FnDt71hhitoDj45U+8IkqL9t6L5jHE9rmJd57z4ykQ l/wA== X-Gm-Message-State: AGRZ1gIGWWDnCXqLzDhCP4jyLHqvWBNc0zdtf6++tUNm//Lko/t5Qyrc PkqKf0K/5x1Up+TsOt0DBBVpDiJHWnkaT8zXaJLG1w== X-Received: by 2002:a1f:984e:: with SMTP id a75mr1230107vke.89.1540990573640; Wed, 31 Oct 2018 05:56:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:f48d:0:0:0:0:0 with HTTP; Wed, 31 Oct 2018 05:56:12 -0700 (PDT) In-Reply-To: <4beaaae77bea4cc5b4cc15504331c9a9@AcuMS.aculab.com> References: <20181029175322.189042-1-dancol@google.com> <4beaaae77bea4cc5b4cc15504331c9a9@AcuMS.aculab.com> From: Daniel Colascione Date: Wed, 31 Oct 2018 12:56:12 +0000 Message-ID: Subject: Re: [RFC PATCH] Minimal non-child process exit notification support To: David Laight Cc: "linux-kernel@vger.kernel.org" , "timmurray@google.com" , "joelaf@google.com" 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 On Wed, Oct 31, 2018 at 12:27 PM, David Laight wrote: > From: Daniel Colascione >> Sent: 29 October 2018 17:53 >> >> This patch adds a new file under /proc/pid, /proc/pid/exithand. >> Attempting to read from an exithand file will block until the >> corresponding process exits, at which point the read will successfully >> complete with EOF. The file descriptor supports both blocking >> operations and poll(2). It's intended to be a minimal interface for >> allowing a program to wait for the exit of a process that is not one >> of its children. > > Why do you need an extra file? Because no current file suffices. > It ought to be possible to use poll() to wait for POLLERR having set > 'events' to zero on any of the nodes in /proc/pid - or even on > the directory itself. That doesn't actually work today. And waiting on a directory with POLLERR would be very weird, since directories in general don't do things like blocking reads or poll support. A separate file with self-contained, well-defined semantics is cleaner. > Indeed, to avoid killing the wrong process you need to have opened > some node of /proc/pid/* (maybe cmdline) before sending the kill > signal. The kernel really needs better documentation of the semantics of procfs file descriptors. You're not the only person to think, mistakenly, that keeping a reference to a /proc/$PID/something FD reserves $PID and prevents it being used for another process. Procfs FDs do no such thing. kill(2) is unsafe whether or not /proc/pid/cmdline or any other /proc file is open.