From owner-freebsd-hackers@freebsd.org Fri Mar 3 23:17:50 2017 Return-Path: Delivered-To: freebsd-hackers@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 E8835CF7638 for ; Fri, 3 Mar 2017 23:17:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85B501536 for ; Fri, 3 Mar 2017 23:17:49 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 9ca835fa-0067-11e7-95b5-6dfd7dbb0ee5 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 9ca835fa-0067-11e7-95b5-6dfd7dbb0ee5; Fri, 03 Mar 2017 23:17:48 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id v23NHboR002145; Fri, 3 Mar 2017 16:17:37 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1488583057.69705.3.camel@freebsd.org> Subject: Re: kill -0 --- side effect or supported From: Ian Lepore To: "Ngie Cooper (yaneurabeya)" , Dirk-Willem van Gulik Cc: freebsd-hackers@freebsd.org Date: Fri, 03 Mar 2017 16:17:37 -0700 In-Reply-To: <11A4B6AB-E51D-4754-8E80-4503687E0F84@gmail.com> References: <23F3BAC3-0D8B-4290-8DC2-818D67A0B6A9@webweaving.org> <11A4B6AB-E51D-4754-8E80-4503687E0F84@gmail.com> Content-Type: text/plain; charset="windows-1251" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2017 23:17:51 -0000 On Fri, 2017-03-03 at 14:23 -0800, Ngie Cooper (yaneurabeya) wrote: > > > > On Mar 3, 2017, at 14:12, Dirk-Willem van Gulik wrote: > > > > I regularly use  'kill -0 ' on FreeBSD as  a way to test if a certain process is still running (but without actually sending the signal). And I think it has worked reliably since the mid 80's. > > > > Is it actually a properly supported use - as I recently happened to notice that it does not seem to be all that documented in kill( > It better work. I have code that relies on it :)… > > It does work as you noted, according to truss: > > # sudo truss -ff kill -0 1 2>&1 > ... > 79940: kill(1,0)                                 = 0 (0x0) > … > # > > As noted in kill(2), this is one of the valid values: > >      a group of processes.  The sig argument may be one of the signals >      specified in sigaction(2) or it may be 0, in which case error checking is >      performed but no signal is actually sent.  This can be used to check the >      validity of pid. > > So, the manpage for kill(1) is just lacking in the sense that -0 is supported. > > Cheers! > -Ngie An interesting point related to "error checking is performed"... one of the error checks is "do you have permission to send a signal to this process?"  That means that kill -0 can only be used to check whether a process you have permission to control is running.   For example "killall -0 ntpd" cannot tell you whether ntpd is running unless you are root. -- Ian