Created attachment 252342 [details] Patch for adding -C option I needed to get the pid of a process started by daemon(8) but without using its supervising functionality of --child-pidfile (and therefore without the need of having daemon(8) hang around as another process). The attached patch adds an option -C to accomplish this.
Created attachment 252343 [details] Patch for adding -C option Correct version of the patch
This seems ok to me, I cc'ed a few folks who have hacked on daemon(8) recently. It would be useful to have a patch in the form of git format-patch's output (or you can submit the patch on github), so that author metadata etc. is filled out correctly. It appears that -C has been taken for a different purpose in commit 7618c9e1637caea97723ff8accd60f3dc436b044, so this can't be applied as-is.
If I get it right, it's suitable for situations where the command to be run daemon()-izes itself, does not have any ability to run in foreground and a shell wrapper with $! output written into a file is not a solution? I'd also rephrase the "ID of the executed command" to "PID of the command executed". Other than that, LGTM. And as stated by Mark Johnston, "git format-patch" output would be more usable, or even a review in phabricator (reviews.FreeBSD.org) would be fine.
Didn't know about -C being taken (as I am on 14-STABLE). Of course, any free letter will be fine. Any suggestions? ID <-> PID: The man page talks about ID for -P and -p. Now that you've mentioned it I also think "PID" would be better but then we should change it within the whole man page. Regarding using $!: Yes, this could be used and in fact I have used it until I needed to run "command" as a different user. I tried su but this failed as this very user was not listed in our /etc/login.access. I can look into "git format-patch" but as I use gitup this will probably be something complicated I'd like to avoid ;-). Regarding reviews.freebsd.org: Is this available for "ordinary" users? If yes, is there a manual (or short doc) of how to use it properly? In general: Is there a documentation of the preferred way how to submit stuff like this (for ordinary users)? I didn't find anything on freebsd.org but I might have overlooked something...
The "ID" vs. "PID" argument is valid, let's keep ID then. Regarding -C, it's taken already. Please, do your patch against "main" branch, then backport it to other branches where you need to run it. And if you want to submit, then you can submit it to phabricator for review, as phabricator is open, you can create an account there.
OK, thanks for your feedback -- I just gave it a try: https://reviews.freebsd.org/D46313
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=fe06e383cc64fce8b604d21f8526b91fa6aecc39 commit fe06e383cc64fce8b604d21f8526b91fa6aecc39 Author: Andre Albsmeier <mail@fbsd2.e4m.org> AuthorDate: 2024-08-17 09:20:00 +0000 Commit: Michael Osipov <michaelo@FreeBSD.org> CommitDate: 2026-08-13 14:21:52 +0000 daemon(8): Add option to write pidfile w/o supervising it Co-authored-by: Michael Osipov <michaelo@FreeBSD.org> PR: 280487 Reviewed by: kevans, michaelo MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46313 usr.sbin/daemon/daemon.8 | 19 ++++++++++++++++--- usr.sbin/daemon/daemon.c | 27 +++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=79f020ffcad205ef82b0a098fd356dbbc5fba8cd commit 79f020ffcad205ef82b0a098fd356dbbc5fba8cd Author: Andre Albsmeier <mail@fbsd2.e4m.org> AuthorDate: 2024-08-17 09:20:00 +0000 Commit: Michael Osipov <michaelo@FreeBSD.org> CommitDate: 2026-08-22 21:12:10 +0000 daemon(8): Add option to write pidfile w/o supervising it Co-authored-by: Michael Osipov <michaelo@FreeBSD.org> PR: 280487 Reviewed by: kevans, michaelo MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46313 (cherry picked from commit fe06e383cc64fce8b604d21f8526b91fa6aecc39) usr.sbin/daemon/daemon.8 | 19 ++++++++++++++++--- usr.sbin/daemon/daemon.c | 27 +++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=21f5c8438851ed2a8ac9251a42648999f8b36439 commit 21f5c8438851ed2a8ac9251a42648999f8b36439 Author: Andre Albsmeier <mail@fbsd2.e4m.org> AuthorDate: 2024-08-17 09:20:00 +0000 Commit: Michael Osipov <michaelo@FreeBSD.org> CommitDate: 2026-08-22 21:13:51 +0000 daemon(8): Add option to write pidfile w/o supervising it Co-authored-by: Michael Osipov <michaelo@FreeBSD.org> PR: 280487 Reviewed by: kevans, michaelo MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46313 (cherry picked from commit fe06e383cc64fce8b604d21f8526b91fa6aecc39) usr.sbin/daemon/daemon.8 | 19 ++++++++++++++++--- usr.sbin/daemon/daemon.c | 27 +++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-)