" -i | --idle set policy to SCHED_IDLE\n"
" -o | --other set policy to SCHED_OTHER\n"
" -r | --rr set policy to SCHED_RR (default)\n"
+ "\nScheduling flags:\n"
+ " -R | --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"
"\nOptions:\n"
" -h | --help display this help\n"
" -p | --pid operate on existing given pid\n"
int main(int argc, char *argv[])
{
- int i, policy = SCHED_RR, priority = 0, verbose = 0;
+ int i, policy = SCHED_RR, priority = 0, verbose = 0, policy_flag = 0;
struct sched_param sp;
pid_t pid = -1;
{ "max", 0, NULL, 'm' },
{ "other", 0, NULL, 'o' },
{ "rr", 0, NULL, 'r' },
+ { "reset-on-fork", 0, NULL, 'R' },
{ "verbose", 0, NULL, 'v' },
{ "version", 0, NULL, 'V' },
{ NULL, 0, NULL, 0 }
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while((i = getopt_long(argc, argv, "+bfiphmorvV", longopts, NULL)) != -1)
+ while((i = getopt_long(argc, argv, "+bfiphmoRrvV", longopts, NULL)) != -1)
{
int ret = EXIT_FAILURE;
case 'f':
policy = SCHED_FIFO;
break;
+ case 'R':
+ policy_flag |= SCHED_RESET_ON_FORK;
+ break;
case 'i':
#ifdef SCHED_IDLE
policy = SCHED_IDLE;
if (errno)
err(EXIT_FAILURE, _("failed to parse priority"));
+ /* sanity check */
+ if ((policy_flag & SCHED_RESET_ON_FORK) &&
+ !(policy == SCHED_FIFO || policy == SCHED_RR))
+ errx(EXIT_FAILURE, _("SCHED_RESET_ON_FORK flag is suppoted for "
+ "SCHED_FIFO and SCHED_RR policies only"));
+
+ policy |= policy_flag;
+
if (pid == -1)
pid = 0;
sp.sched_priority = priority;