View | Details | Raw Unified | Return to bug 254511 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/daemon/daemon.8 (-1 / +16 lines)
Lines 39-44 Link Here
39
.Op Fl P Ar supervisor_pidfile
39
.Op Fl P Ar supervisor_pidfile
40
.Op Fl t Ar title
40
.Op Fl t Ar title
41
.Op Fl u Ar user
41
.Op Fl u Ar user
42
.Op Fl e Ar priority
43
.Op Fl i Ar priority
42
.Op Fl m Ar output_mask
44
.Op Fl m Ar output_mask
43
.Op Fl o Ar output_file
45
.Op Fl o Ar output_file
44
.Op Fl s Ar syslog_priority
46
.Op Fl s Ar syslog_priority
Lines 60-65 Link Here
60
.It Fl c
62
.It Fl c
61
Change the current working directory to the root
63
Change the current working directory to the root
62
.Pq Dq Pa / .
64
.Pq Dq Pa / .
65
.It Fl e Ar priority
66
Set the realtime priority level for the daemonized process.
67
.It Fl i Ar priority
68
Set the idle priority level for the daemonized process.
63
.It Fl f
69
.It Fl f
64
Redirect standard input, standard output and standard error to
70
Redirect standard input, standard output and standard error to
65
.Pa /dev/null .
71
.Pa /dev/null .
Lines 191-196 Link Here
191
stop the service, causing
197
stop the service, causing
192
.Nm
198
.Nm
193
to restart the child.
199
to restart the child.
200
.Pp
201
Options
202
.Fl e ,
203
.Fl i
204
requre a
205
.Ar priority
206
argument which is an integer between 0 and RTP_PRIO_MAX (usually 31).
194
.Sh EXIT STATUS
207
.Sh EXIT STATUS
195
The
208
The
196
.Nm
209
.Nm
Lines 209-215 Link Here
209
.Ar output_mask
222
.Ar output_mask
210
is not within the accepted range, 7 if
223
is not within the accepted range, 7 if
211
.Ar output_file
224
.Ar output_file
212
cannot be opened for appending, and otherwise 0.
225
cannot be opened for appending, 8 if process
226
.Ar priority
227
value can't be accepted and otherwise 0.
213
.Sh DIAGNOSTICS
228
.Sh DIAGNOSTICS
214
If the command cannot be executed, an error message is printed to
229
If the command cannot be executed, an error message is printed to
215
standard error.
230
standard error.
(-)usr.sbin/daemon/daemon.c (-1 / +24 lines)
Lines 35-40 Link Here
35
35
36
#include <sys/param.h>
36
#include <sys/param.h>
37
#include <sys/mman.h>
37
#include <sys/mman.h>
38
#include <sys/rtprio.h>
39
#include <sys/types.h>
38
#include <sys/wait.h>
40
#include <sys/wait.h>
39
41
40
#include <fcntl.h>
42
#include <fcntl.h>
Lines 86-91 Link Here
86
	int pfd[2] = { -1, -1 }, outfd = -1;
88
	int pfd[2] = { -1, -1 }, outfd = -1;
87
	int stdmask, logpri, logfac;
89
	int stdmask, logpri, logfac;
88
	struct pidfh *ppfh, *pfh;
90
	struct pidfh *ppfh, *pfh;
91
	struct rtprio rtp, *prtp = NULL;
89
	char *p;
92
	char *p;
90
93
91
	memset(&logpar, 0, sizeof(logpar));
94
	memset(&logpar, 0, sizeof(logpar));
Lines 99-109 Link Here
99
	dosyslog = 0;
102
	dosyslog = 0;
100
	outfn = NULL;
103
	outfn = NULL;
101
	title = NULL;
104
	title = NULL;
102
	while ((ch = getopt(argc, argv, "cfSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) {
105
	while ((ch = getopt(argc, argv, "ce:i:fSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) {
103
		switch (ch) {
106
		switch (ch) {
104
		case 'c':
107
		case 'c':
105
			nochdir = 0;
108
			nochdir = 0;
106
			break;
109
			break;
110
		case 'e':
111
		case 'i':
112
			switch (ch) {
113
			case 'e':
114
				rtp.type = RTP_PRIO_REALTIME;
115
				break;
116
			case 'i':
117
				rtp.type = RTP_PRIO_IDLE;
118
				break;
119
			}
120
			rtp.prio = strtol(optarg, &p, 10);
121
			if (p != optarg + strlen(optarg) || rtp.prio < 0 || rtp.prio > RTP_PRIO_MAX)
122
				errx(8, "unrecognized priority value");
123
			prtp = &rtp;
124
			break;
107
		case 'f':
125
		case 'f':
108
			noclose = 0;
126
			noclose = 0;
109
			break;
127
			break;
Lines 279-284 Link Here
279
		/* Now that we are the child, write out the pid. */
297
		/* Now that we are the child, write out the pid. */
280
		pidfile_write(pfh);
298
		pidfile_write(pfh);
281
299
300
		/* Set child's priority if requested. */
301
		if (prtp != NULL)
302
			if (rtprio(RTP_SET, getpid(), prtp) != 0)
303
				err(1, "RTP_SET");
304
282
		if (user != NULL)
305
		if (user != NULL)
283
			restrict_process(user);
306
			restrict_process(user);
284
		/*
307
		/*

Return to bug 254511