From nobody Thu Aug 14 16:03:13 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c2qlj42scz64fwS; Thu, 14 Aug 2025 16:03:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c2qlj1vD1z3KQ8; Thu, 14 Aug 2025 16:03:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755187393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AQrwnPXxuLMj7IXp2sopIdo/nnfqcp5+zBN8AmhypXQ=; b=A+j3ef5sY+qyuwfTZ6hNlvhrAbwMqIyDD7wRdnXdk2fPWrDdBkNmqCWRnwlZqx1GPOqd4j pp6maDFb00/EqPHc6VIPr/EiuKe0IjuTaaDwz4cej2qV0m5OgXE6LGKUN/rsb+z7pRNlQ9 qtfnfmb8xX1KeODAp143RQEo5lUuwu+UQzNuD36dzZ2TWdzD1RmmJc2Y5cz2IQh8Uooazt SEpGf+Oc8OB+TFg7zx4LsLlHivhKzRlSF8f0EV4P3Sh739bTbAgJ3ItA5yHCPSe5s2S5s5 kA3s1pyRjjbAqqtRuNW1LvRjr2/nLxvj6m7lN0sg4gEwmcHiZkwm5ad94rCYEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755187393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AQrwnPXxuLMj7IXp2sopIdo/nnfqcp5+zBN8AmhypXQ=; b=xABIRvTwD01J8Qp4CvrtYOcn0ESwH3RXsN2f4dL5dvr1eAW4gsIQapZ5vIkzl4OeHqIuT8 8apU4Ho7zY/T6tY9YxE+uOqjcDDNXXwkvR9wrnmxXVBFzQnAOmEoHwLtq8V9ABtL01dWVc GzP0hVX9i56KNVbBIkA29edAA/INabtUKhwtXe7vRBSHxmg9jd0rv+s73rMWgrEm47JBFY 1xT1oY+righvSTbVOtD83HAr6WPC3w8NivObCi7zuifO0iSiJaLsaUADj9LZr1Mrs56iVX sJc54vLB60A6evhhN1y1amS4GUnaKMk1u4nF/lyv8SIShuXmk1qrjs8KJFUKvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755187393; a=rsa-sha256; cv=none; b=cD+S4kaFmQTrrBfNob1nabFy48TiLJ8NQoHDGxA5UMKKlZZ3zkTSBkLv/56VdHEAKjamc+ yWoRE5ClU5KJ68UY4XNeyIo34GiDTUXYn41kpepTnLFUaygwP79C0ws3oLyInt00e1G+Nz 9aXdrp3ncez6E0BVbZ5rWodMv3U6W0gaNiY5EUGTY8R/j56NzJyXtcXNLswhqMLFdM4cLU T68F56JoSsFX6QKsorQFPsg+HtRITIP3GtSFQ8fP271YXlqPbIhNQXsIpfR7FEPKdqKc5Z N/f9d7wsQu1Q+xd6OZHuLYgVkaLrtFtp9W/WM3/d7x0cdZm/reXk0IhX3mAwLg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4c2qlj1JTHz10XG; Thu, 14 Aug 2025 16:03:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57EG3DOJ079852; Thu, 14 Aug 2025 16:03:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57EG3DKt079849; Thu, 14 Aug 2025 16:03:13 GMT (envelope-from git) Date: Thu, 14 Aug 2025 16:03:13 GMT Message-Id: <202508141603.57EG3DKt079849@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: f580383f1e3e - stable/13 - libutil: Document pidfile_signal() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f580383f1e3e773608dcd7136ba9ebf3914b0548 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=f580383f1e3e773608dcd7136ba9ebf3914b0548 commit f580383f1e3e773608dcd7136ba9ebf3914b0548 Author: Dag-Erling Smørgrav AuthorDate: 2025-08-03 17:31:20 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-08-14 14:00:05 +0000 libutil: Document pidfile_signal() Fixes: 287451fd0192 MFC after: 1 week Reviewed by: pauamma_gundo.com, emaste Differential Revision: https://reviews.freebsd.org/D51705 (cherry picked from commit 4e6a3e7e3240a95cda1d490831aa16ed3b9bd59b) --- lib/libutil/pidfile.3 | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3 index c4786736d28f..d28d5ed8eccb 100644 --- a/lib/libutil/pidfile.3 +++ b/lib/libutil/pidfile.3 @@ -22,14 +22,16 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 10, 2020 +.Dd August 2, 2025 .Dt PIDFILE 3 .Os .Sh NAME .Nm pidfile_open , .Nm pidfile_write , .Nm pidfile_close , -.Nm pidfile_remove +.Nm pidfile_remove , +.Nm pidfile_fileno , +.Nm pidfile_signal .Nd "library for PID files handling" .Sh LIBRARY .Lb libutil @@ -45,6 +47,8 @@ .Fn pidfile_remove "struct pidfh *pfh" .Ft int .Fn pidfile_fileno "struct pidfh *pfh" +.Ft int +.Fn pidfile_signal "const char *path" "int sig" "pid_t *pidptr" .Sh DESCRIPTION The .Nm pidfile @@ -101,6 +105,26 @@ function closes and removes a pidfile. The .Fn pidfile_fileno function returns the file descriptor for the open pidfile. +.Pp +The +.Fn pidfile_signal +function looks for the pidfile specified by +.Va path , +and if it exists and is locked, sends the signal specified by +.Va sig +to the PID it contains. +If +.Va pidptr +is not +.Dv NULL , +the PID that was found in the pidfile is stored in the location it +points to. +Note that calling +.Fn pidfile_signal +with +.Va sig +set to zero is an effective way to verify the existence of a pidfile +and of the process that owns it. .Sh RETURN VALUES The .Fn pidfile_open @@ -125,6 +149,13 @@ and sets if a NULL .Vt pidfh is specified, or if the pidfile is no longer open. +.Pp +The +.Fn pidfile_signal +function returns 0 if it successfully signaled a process, and an +appropriate +.Va errno +value otherwise. .Sh EXAMPLES The following example shows in which order these functions should be used. Note that it is safe to pass @@ -132,7 +163,7 @@ Note that it is safe to pass to .Fn pidfile_write , .Fn pidfile_remove , -.Fn pidfile_close +.Fn pidfile_close , and .Fn pidfile_fileno functions. @@ -280,7 +311,28 @@ Improper function use. Probably called not from the process which used .Fn pidfile_open . .El +.Pp +The +.Fn pidfile_signal +function will fail if: +.Bl -tag -width Er +.It Bq Er ENOENT +The pidfile does not exist, or exists but is not locked. +.It Bq Er EDOM +The pidfile contains a negative number. +.El +.Pp +The +.Fn pidfile_signal +function may also fail and return any of the +.Va errno +values specified for the +.Fn pidfile_read +function and the +.Xr kill 2 +system call. .Sh SEE ALSO +.Xr kill 2 , .Xr open 2 , .Xr daemon 3 , .Xr flopen 3 @@ -288,11 +340,19 @@ Probably called not from the process which used The functions .Fn pidfile_open , .Fn pidfile_write , -.Fn pidfile_close +.Fn pidfile_close , and .Fn pidfile_remove first appeared in .Fx 5.5 . +The +.Fn pidfile_fileno +function was added in +.Fx 9.1 . +The +.Fn pidfile_signal +function was added in +.Fx 14.0 . .Sh AUTHORS .An -nosplit The