diff options
Diffstat (limited to 'usr.sbin/daemon')
-rw-r--r-- | usr.sbin/daemon/daemon.8 | 8 | ||||
-rw-r--r-- | usr.sbin/daemon/daemon.c | 14 |
2 files changed, 16 insertions, 6 deletions
diff --git a/usr.sbin/daemon/daemon.8 b/usr.sbin/daemon/daemon.8 index 87cfd980aec2..dab9e3f2ab9c 100644 --- a/usr.sbin/daemon/daemon.8 +++ b/usr.sbin/daemon/daemon.8 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 13, 2013 +.Dd March 2, 2016 .Dt DAEMON 8 .Os .Sh NAME @@ -37,6 +37,7 @@ .Op Fl cfr .Op Fl p Ar child_pidfile .Op Fl P Ar supervisor_pidfile +.Op Fl t Ar title .Op Fl u Ar user .Ar command arguments ... .Sh DESCRIPTION @@ -94,6 +95,8 @@ regardless of whether the option is used or not. .It Fl r Supervise and restart the program if it has been terminated. +.It Fl t Ar title +Process title for the daemon to make it easily identifiable. .It Fl u Ar user Login name of the user to execute the program under. Requires adequate superuser privileges. @@ -123,7 +126,8 @@ option is useful combined with the option as .Ar supervisor_pidfile contains the ID of the supervisor -not the child. This is especially important if you use +not the child. +This is especially important if you use .Fl r in an rc script as the .Fl p diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index 7bdd2a6183d9..bd2f2722a0d7 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -56,13 +56,13 @@ main(int argc, char *argv[]) struct pidfh *ppfh, *pfh; sigset_t mask, oldmask; int ch, nochdir, noclose, restart, serrno; - const char *pidfile, *ppidfile, *user; + const char *pidfile, *ppidfile, *title, *user; pid_t otherpid, pid; nochdir = noclose = 1; restart = 0; - ppidfile = pidfile = user = NULL; - while ((ch = getopt(argc, argv, "cfp:P:ru:")) != -1) { + ppidfile = pidfile = title = user = NULL; + while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) { switch (ch) { case 'c': nochdir = 0; @@ -79,6 +79,9 @@ main(int argc, char *argv[]) case 'r': restart = 1; break; + case 't': + title = optarg; + break; case 'u': user = optarg; break; @@ -204,7 +207,10 @@ restart: err(1, "%s", argv[0]); } - setproctitle("%s[%d]", argv[0], pid); + if (title != NULL) + setproctitle("%s[%d]", title, pid); + else + setproctitle("%s[%d]", argv[0], pid); if (wait_child(pid, &mask) == 0 && restart) { sleep(1); goto restart; |