From nobody Sat Jun 27 01:11:39 2026 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 4gnDyg26p6z6jGnQ for ; Sat, 27 Jun 2026 01:11:39 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gnDyg1Cltz3DFn for ; Sat, 27 Jun 2026 01:11:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782522699; 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=mfIA0CO2l0Jgn/uzrTr9svnv6N+HbSHSEJY2z4hI+XU=; b=QI0efwC/D5Twr/m3QnWk0OeDKt5HF6cpOaFyDrwPoC0OH3nKNKOFb8qy9seTZMdblAADWf Yri/jfy1SNwEkzZRuCpHO+HF293F8qXa9Y+UI5oH0NkKssfzSkciwxq92PR/pYsQQKu8Bl ZoJKEChuYYL9+8T5P2F/E/j1NLC62E1g3QemA4B5+AF1F/SWi3b54pjaAksL4DuWbuRwY6 LTZrQdBIUUa1gQ444RpJACkr+hE2jh+KoTEAAggC86Ix3TEz5Slnm0KC/slCg9OJQVa7Rg uJ8gTR35J9DJZwg3RP+9drrqUIw+w5BCbnYK06n8iKIk1QxAndTg6Ji83Fl1vA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782522699; a=rsa-sha256; cv=none; b=Y5556k4DCUWl+c9NQIKYJmgMrsD2jqgBcOtY1OwqJEkvLJ6BPo67EAliDdXO9Y9ecPaAuA KYjhqniXCqx2PPEu4wOOsHZP8DphER4smtXs6OPQJA5Ml4H2rdKgpmishalOLf8UvkaWIh LpmzPVq3a4Iz8LuFSrAnbX6aCEVdv5K+rhJLsyhnD/SU6FASKCTok8h7DteMx31TXR8ck4 MSBt0ZDgchfknf29/pUShxKWwbbqI0tIM4sJ2yJJPdq6/suuwoZrwUxhDLIQ12OusFmOkF p6auQLt2yIqoiuvfl4kWKRMKC0mfIIPp28i2TqKH7yTYeUSspS1xrD62PmiO1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782522699; 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=mfIA0CO2l0Jgn/uzrTr9svnv6N+HbSHSEJY2z4hI+XU=; b=pE59BTW7qfSCOlQIek5n7TvlMsFv33uifAZLqlTc6dg39suR155qWsweHbfUZiXkDlFFVo xpSxUOckp94jyZ8Rf1ctcTp1RcnpAKwoqYSh0/Xy9bzVgaX8ahfd3iGFrzFIrNkPtql4zE 05m8uYJNEUox9jH2rPWsTe+feuiJdiwbyEiQcGz+uySjpdD+D3Lk0okpvFdiUTvGgSkukt Le/5cmxI/ikvgqHvnIOqm/u1QSScFzOoQ3PW88yfUutFO8ovLRwtQsRI63fKKi7r2X2uCg 1JmOX0zVQqp/+5+8US7HF6dYQtJCmw/56cjT2RuQnQfVjNnHYFAo/WMz0BPWqQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gnDyg04msz12hb for ; Sat, 27 Jun 2026 01:11:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18fcb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 27 Jun 2026 01:11:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Aymeric Wibo Subject: git: e1f80e4902a4 - stable/15 - daemon(3): Note about environment after calling daemon() 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obiwac X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e1f80e4902a40cc13d4a6e3131bca1fc7c5809d6 Auto-Submitted: auto-generated Date: Sat, 27 Jun 2026 01:11:39 +0000 Message-Id: <6a3f234b.18fcb.204bd5af@gitrepo.freebsd.org> The branch stable/15 has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=e1f80e4902a40cc13d4a6e3131bca1fc7c5809d6 commit e1f80e4902a40cc13d4a6e3131bca1fc7c5809d6 Author: Aymeric Wibo AuthorDate: 2026-06-17 19:51:39 +0000 Commit: Aymeric Wibo CommitDate: 2026-06-27 01:09:38 +0000 daemon(3): Note about environment after calling daemon() While here, fix missing comma typo. Reviewed by: 0mp, ziaee Approved by: 0mp, ziaee MFC after: 3 days Obtained from: https://github.com/apple-oss-distributions/libc (partially) Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D57384 (cherry picked from commit bb14ba3777bb201abd6d4dfbf67d70b81f9c1e97) --- lib/libc/gen/daemon.3 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3 index 4619ba3489aa..99a4f685bedb 100644 --- a/lib/libc/gen/daemon.3 +++ b/lib/libc/gen/daemon.3 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 27, 2023 +.Dd June 1, 2026 .Dt DAEMON 3 .Os .Sh NAME @@ -44,6 +44,13 @@ The .Fn daemon function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons. +The +.Xr fork 2 +system call is used; see +.Sx CAVEATS +below about the environment after a +.Fn fork +.Pq without a corresponding call to one of the exec routines . .Pp If the argument .Fa nochdir @@ -89,7 +96,7 @@ and function may fail and set .Va errno for any of the errors specified for the library functions -.Xr fork 2 +.Xr fork 2 , .Xr open 2 , and .Xr setsid 2 . @@ -107,6 +114,21 @@ The function first appeared in .Fx 12.0 . .Sh CAVEATS +In multithreaded programs, the child process after +.Fn fork +inherits copies of all mutexes and other synchronization state, but only the +calling thread survives. +Any locks held by other threads at the time of the call will remain permanently +acquired in the child, causing deadlocks in any code that attempts to +acquire them. +Until one of the +.Xr exec 3 +functions is called, the child should restrict itself to async-signal safe +operations +.Po see +.Xr sigaction 2 +.Pc . +.Pp Unless the .Fa noclose argument is non-zero,