FreeBSD Bugzilla – Attachment 223530 Details for
Bug 254511
daemon(8): Allow to set daemonized process realtime or idletime scheduling priority
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
daemon-add-priority.patch
daemon-add-priority.patch (text/plain), 2.78 KB, created by
Yuri Victorovich
on 2021-03-23 18:28:30 UTC
(
hide
)
Description:
daemon-add-priority.patch
Filename:
MIME Type:
Creator:
Yuri Victorovich
Created:
2021-03-23 18:28:30 UTC
Size:
2.78 KB
patch
obsolete
>Index: usr.sbin/daemon/daemon.8 >=================================================================== >--- usr.sbin/daemon/daemon.8 (revision 369506) >+++ usr.sbin/daemon/daemon.8 (working copy) >@@ -39,6 +39,8 @@ > .Op Fl P Ar supervisor_pidfile > .Op Fl t Ar title > .Op Fl u Ar user >+.Op Fl e Ar priority >+.Op Fl i Ar priority > .Op Fl m Ar output_mask > .Op Fl o Ar output_file > .Op Fl s Ar syslog_priority >@@ -60,6 +62,10 @@ > .It Fl c > Change the current working directory to the root > .Pq Dq Pa / . >+.It Fl e Ar priority >+Set the realtime priority level for the daemonized process. >+.It Fl i Ar priority >+Set the idle priority level for the daemonized process. > .It Fl f > Redirect standard input, standard output and standard error to > .Pa /dev/null . >@@ -191,6 +197,13 @@ > stop the service, causing > .Nm > to restart the child. >+.Pp >+Options >+.Fl e , >+.Fl i >+requre a >+.Ar priority >+argument which is an integer between 0 and RTP_PRIO_MAX (usually 31). > .Sh EXIT STATUS > The > .Nm >@@ -209,7 +222,9 @@ > .Ar output_mask > is not within the accepted range, 7 if > .Ar output_file >-cannot be opened for appending, and otherwise 0. >+cannot be opened for appending, 8 if process >+.Ar priority >+value can't be accepted and otherwise 0. > .Sh DIAGNOSTICS > If the command cannot be executed, an error message is printed to > standard error. >Index: usr.sbin/daemon/daemon.c >=================================================================== >--- usr.sbin/daemon/daemon.c (revision 369506) >+++ usr.sbin/daemon/daemon.c (working copy) >@@ -35,6 +35,8 @@ > > #include <sys/param.h> > #include <sys/mman.h> >+#include <sys/rtprio.h> >+#include <sys/types.h> > #include <sys/wait.h> > > #include <fcntl.h> >@@ -86,6 +88,7 @@ > int pfd[2] = { -1, -1 }, outfd = -1; > int stdmask, logpri, logfac; > struct pidfh *ppfh, *pfh; >+ struct rtprio rtp, *prtp = NULL; > char *p; > > memset(&logpar, 0, sizeof(logpar)); >@@ -99,11 +102,26 @@ > dosyslog = 0; > outfn = NULL; > title = NULL; >- while ((ch = getopt(argc, argv, "cfSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) { >+ while ((ch = getopt(argc, argv, "ce:i:fSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) { > switch (ch) { > case 'c': > nochdir = 0; > break; >+ case 'e': >+ case 'i': >+ switch (ch) { >+ case 'e': >+ rtp.type = RTP_PRIO_REALTIME; >+ break; >+ case 'i': >+ rtp.type = RTP_PRIO_IDLE; >+ break; >+ } >+ rtp.prio = strtol(optarg, &p, 10); >+ if (p != optarg + strlen(optarg) || rtp.prio < 0 || rtp.prio > RTP_PRIO_MAX) >+ errx(8, "unrecognized priority value"); >+ prtp = &rtp; >+ break; > case 'f': > noclose = 0; > break; >@@ -279,6 +297,11 @@ > /* Now that we are the child, write out the pid. */ > pidfile_write(pfh); > >+ /* Set child's priority if requested. */ >+ if (prtp != NULL) >+ if (rtprio(RTP_SET, getpid(), prtp) != 0) >+ err(1, "RTP_SET"); >+ > if (user != NULL) > restrict_process(user); > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 254511
:
223530
|
223535
|
223536
|
223537