From owner-svn-src-all@freebsd.org Wed Mar 2 19:10:41 2016 Return-Path: Delivered-To: svn-src-all@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 86F97AC0DEA; Wed, 2 Mar 2016 19:10:41 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 48BF313D7; Wed, 2 Mar 2016 19:10:41 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u22JAenb016956; Wed, 2 Mar 2016 19:10:40 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u22JAe6F016954; Wed, 2 Mar 2016 19:10:40 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201603021910.u22JAe6F016954@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Wed, 2 Mar 2016 19:10:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296321 - head/usr.sbin/daemon X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2016 19:10:41 -0000 Author: cem Date: Wed Mar 2 19:10:39 2016 New Revision: 296321 URL: https://svnweb.freebsd.org/changeset/base/296321 Log: daemon(8): Add -t option to set process title The default process title is taken from the argv[0] value (any particular hardlink name). Add a -t option to override the default. PR: 205016 Submitted by: Yuri No objection from: freebsd-current@ Sponsored by: EMC / Isilon Storage Division Modified: head/usr.sbin/daemon/daemon.8 head/usr.sbin/daemon/daemon.c Modified: head/usr.sbin/daemon/daemon.8 ============================================================================== --- head/usr.sbin/daemon/daemon.8 Wed Mar 2 18:46:17 2016 (r296320) +++ head/usr.sbin/daemon/daemon.8 Wed Mar 2 19:10:39 2016 (r296321) @@ -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 Modified: head/usr.sbin/daemon/daemon.c ============================================================================== --- head/usr.sbin/daemon/daemon.c Wed Mar 2 18:46:17 2016 (r296320) +++ head/usr.sbin/daemon/daemon.c Wed Mar 2 19:10:39 2016 (r296321) @@ -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;