From a96932103e6e1d124c86911d894268a0eff2c152 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 12 Apr 2021 16:21:18 +0200 Subject: [PATCH] chrt: non-Linux fix Reported-by: Samuel Thibault Signed-off-by: Karel Zak --- schedutils/chrt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 052ad7a1b..b8890b3aa 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -214,6 +214,7 @@ fallback: static void show_sched_info(struct chrt_ctl *ctl) { if (ctl->all_tasks) { +#ifdef __linux__ pid_t tid; struct proc_tasks *ts = proc_open_tasks(ctl->pid); @@ -224,6 +225,9 @@ static void show_sched_info(struct chrt_ctl *ctl) show_sched_pid_info(ctl, tid); proc_close_tasks(ts); +#else + err(EXIT_FAILURE, _("cannot obtain the list of tasks")); +#endif } else show_sched_pid_info(ctl, ctl->pid); } @@ -320,6 +324,7 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid) static void set_sched(struct chrt_ctl *ctl) { if (ctl->all_tasks) { +#ifdef __linux__ pid_t tid; struct proc_tasks *ts = proc_open_tasks(ctl->pid); @@ -331,7 +336,9 @@ static void set_sched(struct chrt_ctl *ctl) err(EXIT_FAILURE, _("failed to set tid %d's policy"), tid); proc_close_tasks(ts); - +#else + err(EXIT_FAILURE, _("cannot obtain the list of tasks")); +#endif } else if (set_sched_one(ctl, ctl->pid) == -1) err(EXIT_FAILURE, _("failed to set pid %d's policy"), ctl->pid);