Specifies deadline parameter for SCHED_DEADLINE policy (Linux-specific).
.TP
\fB\-R\fR, \fB\-\-reset-on-fork\fR
-Add
+Use
.B SCHED_RESET_ON_FORK
-flag to the
+or
+.B SCHED_FLAG_RESET_ON_FORK
+flag. Linux-specific, supported since 2.6.31.
+
+Each thread has a reset-on-fork scheduling flag. When this flag is set, children created by
+.BR fork (2)
+do not inherit privileged scheduling policies. After the reset-on-fork flag has been enabled,
+it can be reset only if the thread has the
+.BR CAP_SYS_NICE
+capability. This flag is disabled in child processes created by
+.BR fork (2).
+
+More precisely, if the reset-on-fork flag is set,
+the following rules apply for subsequently created children:
+.RS
+.IP * 3
+If the calling thread has a scheduling policy of
.B SCHED_FIFO
or
-.B SCHED_RR
-scheduling policy (Linux-specific, supported since 2.6.31).
+.BR SCHED_RR ,
+the policy is reset to
+.BR SCHED_OTHER
+in child processes.
+.IP *
+If the calling process has a negative nice value,
+the nice value is reset to zero in child processes.
+.RE
+
+
.SH OPTIONS
.TP
fputs(USAGE_SEPARATOR, out);
fputs(_("Scheduling options:\n"), out);
- fputs(_(" -R, --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"), out);
+ fputs(_(" -R, --reset-on-fork set reset-on-fork flag\n"), out);
fputs(_(" -T, --sched-runtime <ns> runtime parameter for DEADLINE\n"), out);
fputs(_(" -P, --sched-period <ns> period parameter for DEADLINE\n"), out);
fputs(_(" -D, --sched-deadline <ns> deadline parameter for DEADLINE\n"), out);
static const char *get_policy_name(int policy)
{
+#ifdef SCHED_RESET_ON_FORK
+ policy &= ~SCHED_RESET_ON_FORK;
+#endif
switch (policy) {
case SCHED_OTHER:
return "SCHED_OTHER";
case SCHED_FIFO:
-#ifdef SCHED_RESET_ON_FORK
- case SCHED_FIFO | SCHED_RESET_ON_FORK:
-#endif
return "SCHED_FIFO";
#ifdef SCHED_IDLE
case SCHED_IDLE:
return "SCHED_IDLE";
#endif
case SCHED_RR:
-#ifdef SCHED_RESET_ON_FORK
- case SCHED_RR | SCHED_RESET_ON_FORK:
-#endif
return "SCHED_RR";
#ifdef SCHED_BATCH
case SCHED_BATCH:
else
prio = sp.sched_priority;
# ifdef SCHED_RESET_ON_FORK
- if (policy == (SCHED_FIFO|SCHED_RESET_ON_FORK) || policy == (SCHED_BATCH|SCHED_RESET_ON_FORK))
+ if (policy & SCHED_RESET_ON_FORK)
reset_on_fork = 1;
# endif
}
errno = 0;
ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
-#ifdef SCHED_RESET_ON_FORK
- if (ctl->reset_on_fork && ctl->policy != SCHED_FIFO && ctl->policy != SCHED_RR)
- errx(EXIT_FAILURE, _("--reset-on-fork option is supported for "
- "SCHED_FIFO and SCHED_RR policies only"));
-#endif
#ifdef SCHED_DEADLINE
if ((ctl->runtime || ctl->deadline || ctl->period) && ctl->policy != SCHED_DEADLINE)
errx(EXIT_FAILURE, _("--sched-{runtime,deadline,period} options "