The `--verbose' option is completely broken when `--pid' is not
specified, as it tries to show the current scheduling policy for
nothing:
$ chrt --verbose --other 0 true
chrt: failed to get pid -1's policy: Invalid argument
Fix it by only showing the current scheduling policy if `--pid' and
`--verbose' are both given.
$ chrt --verbose --other 0 true
pid
1549197's new scheduling policy: SCHED_OTHER
pid
1549197's new scheduling priority: 0
pid
1549197's new runtime parameter:
2800000
Fixes: 13346d4d28cd ("chrt: Only display current settings when no policy is specified")
Signed-off-by: Rong Zhang <i@rong.moe>
if (ctl->policy == SCHED_RR)
need_prio = true;
- if (ctl->verbose)
+ if (ctl->pid > -1 && ctl->verbose)
show_sched_info(ctl);
bool have_prio = need_prio ||