From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62433 invoked by alias); 11 Aug 2016 14:13:18 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 62422 invoked by uid 89); 11 Aug 2016 14:13:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-94.0 required=5.0 tests=AWL,BAYES_40,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,RDNS_DYNAMIC autolearn=ham version=3.3.2 spammy=bray, Bray, laid, sk:newlib- X-HELO: calimero.vinschen.de Received: from ipbcc0190b.dynamic.kabel-deutschland.de (HELO calimero.vinschen.de) (188.192.25.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Aug 2016 14:13:07 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 2B760A80402; Thu, 11 Aug 2016 16:13:05 +0200 (CEST) Date: Thu, 11 Aug 2016 16:55:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Cc: Erik Bray Subject: Re: 2.5.1: kill(pid, sig) before waitpid() returns -1 for sig != 0 Message-ID: <20160811141305.3em7tpcrxsushraa@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, Erik Bray References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tzovjvlf5yvyo2q3" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.2-neo (2016-07-23) X-SW-Source: 2016-08/txt/msg00193.txt.bz2 --tzovjvlf5yvyo2q3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1996 Hi Eric, On Aug 11 11:51, Erik Bray wrote: > [...] > > Existing implementations vary on the result of a kill() with pid indica= ting an inactive process (a > > terminated process that has not been waited for by its parent). Some in= dicate success on such a > > call (subject to permission checking), while others give an error of [E= SRCH]. Since the definition > > of process lifetime in this volume of POSIX.1-2008 covers inactive proc= esses, the [ESRCH] error > > as described is inappropriate in this case. In particular, this means t= hat an application cannot > > have a parent process check for termination of a particular child with = kill(). (Usually this is done > > with the null signal; this can be done reliably with waitpid().) >=20 > In response to the originally issue, this was fixed *specifically* for > the case of kill(pid, 0). But my reading of the above is that kill() > should return 0 in this case regardless of the signal (modulo > permissions, etc.). On Linux, for example, when calling kill with pid > of a zombie process the kernel will happily deliver the signal to the > relevant task_struct; it will just never be acted on since the task > will never run again. I'm not sure why cgf only fixed that for sig 0 at the time, since, as you noted, the text from POSIX-1.2008 does not state that this is *restricted* to sig 0. > The below (untested) patch demonstrates the change I'm suggesting, > though I don't know what other code, if any, might be involved in > this. The original patch laid the groundwork by making sure that there are two states, EXITED and REAPED. Removing the explicit check for 0 is the right thing to do, afaics, so I tested and applied your patch as is, see=20 https://cygwin.com/git/?p=3Dnewlib-cygwin.git;a=3Dcommitdiff;h=3D86f79af827= 729f3968d8b3b8f860ac29d200da0d Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --tzovjvlf5yvyo2q3 Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXrIfwAAoJEPU2Bp2uRE+gPbgQAKZme+ZIz7vAiS0qlBSdkMXn Jj+LD6SiMLPLFSeTykI3aooqZnO7XAJhVqQYBIROfyK7R/UCCOalD5eMwiU4BmI/ s20yTN6zIDxRL2cbIxF1XmSLHb3vtGLz3RkFKtUx7ZJJ1avu8SAtkHXyKnj1HKki hEJ3PjI9izV8W+fwM4wd21VDZJrjJsRkIwHAZygkGgVDRomr/bQraIJhZ2CsUALd Gp1v7PXZo+9vkBb9f45hAMQtxGDhPiQ1XUr6Q4Q+G5gQNxBNp5ZjxvFQ7eFwM4KR Kof5ujBlGN5bjPIfFVqfktwZ8haMKlnkqnM95xAThHpPgSi5EKocQKTzjQAtY2// jvc1CQMSMj9Cd3NLFtCo9LLBmJg5p+c4UfP/iEvNMr1ASOMujYM3iAzmFIX2hQrc Nl/sYIzWF2+c+O+aZ0tf1k2zwkWj4Agv+2yJsbY5/QhrGbdJ6HMW5a6j9sASSEbs QHAp/Gqhv/UrgUwy2PU+J2LLb/NBLVZaKVKu5B9DD/a3RxNOOdx9GaoNcp4nMPWE eS/cpyf+qRNQj3XM0/fpWZiaoWqJIrDvOQQsSA7n1mi9DYAFbQoscG5ZZEY6zEHz T+Q0552J9Fl6ZstgSvGQyftfic6xoXnmb6Gdf062xx22JLH+97cxoU5nllRc+JRE lNyyeB7oLtbF+wLWdU+e =PmFE -----END PGP SIGNATURE----- --tzovjvlf5yvyo2q3--