View | Details | Raw Unified | Return to bug 205016
Collapse All | Expand All

(-)usr.sbin/daemon/daemon.8 (+3 lines)
Lines 37-42 Link Here
37
.Op Fl cfr
37
.Op Fl cfr
38
.Op Fl p Ar child_pidfile
38
.Op Fl p Ar child_pidfile
39
.Op Fl P Ar supervisor_pidfile
39
.Op Fl P Ar supervisor_pidfile
40
.Op Fl t Ar title
40
.Op Fl u Ar user
41
.Op Fl u Ar user
41
.Ar command arguments ...
42
.Ar command arguments ...
42
.Sh DESCRIPTION
43
.Sh DESCRIPTION
Lines 94-99 Link Here
94
option is used or not.
95
option is used or not.
95
.It Fl r
96
.It Fl r
96
Supervise and restart the program if it has been terminated.
97
Supervise and restart the program if it has been terminated.
98
.It Fl t Ar title
99
Process title for the daemon to make it easily identifiable.
97
.It Fl u Ar user
100
.It Fl u Ar user
98
Login name of the user to execute the program under.
101
Login name of the user to execute the program under.
99
Requires adequate superuser privileges.
102
Requires adequate superuser privileges.
(-)usr.sbin/daemon/daemon.c (-4 / +11 lines)
Lines 56-68 Link Here
56
	struct pidfh  *ppfh, *pfh;
56
	struct pidfh  *ppfh, *pfh;
57
	sigset_t mask, oldmask;
57
	sigset_t mask, oldmask;
58
	int ch, nochdir, noclose, restart, serrno;
58
	int ch, nochdir, noclose, restart, serrno;
59
	const char *pidfile, *ppidfile,  *user;
59
	const char *pidfile, *ppidfile, *ptitle, *user;
60
	pid_t otherpid, pid;
60
	pid_t otherpid, pid;
61
61
62
	nochdir = noclose = 1;
62
	nochdir = noclose = 1;
63
	restart = 0;
63
	restart = 0;
64
	ppidfile = pidfile = user = NULL;
64
	ppidfile = pidfile = ptitle = user = NULL;
65
	while ((ch = getopt(argc, argv, "cfp:P:ru:")) != -1) {
65
	while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) {
66
		switch (ch) {
66
		switch (ch) {
67
		case 'c':
67
		case 'c':
68
			nochdir = 0;
68
			nochdir = 0;
Lines 79-84 Link Here
79
		case 'r':
79
		case 'r':
80
			restart = 1;
80
			restart = 1;
81
			break;
81
			break;
82
		case 't':
83
			ptitle = optarg;
84
			break;
82
		case 'u':
85
		case 'u':
83
			user = optarg;
86
			user = optarg;
84
			break;
87
			break;
Lines 204-210 Link Here
204
		err(1, "%s", argv[0]);
207
		err(1, "%s", argv[0]);
205
	}
208
	}
206
209
207
	setproctitle("%s[%d]", argv[0], pid);
210
	if (ptitle) {
211
		setproctitle("%s", ptitle);
212
	} else {
213
		setproctitle("%s[%d]", argv[0], pid);
214
	}
208
	if (wait_child(pid, &mask) == 0 && restart) {
215
	if (wait_child(pid, &mask) == 0 && restart) {
209
		sleep(1);
216
		sleep(1);
210
		goto restart;
217
		goto restart;

Return to bug 205016