From 4d791071bafc9d9e8677c99ff28c917649fe9ea0 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 7 Sep 2021 17:39:00 +0200 Subject: [PATCH] chrt: use lib/procfs.c --- schedutils/chrt.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/schedutils/chrt.c b/schedutils/chrt.c index b8890b3aab..250d878063 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -33,7 +33,7 @@ #include "nls.h" #include "closestream.h" #include "strutils.h" -#include "procutils.h" +#include "procfs.h" #include "sched_attr.h" @@ -215,16 +215,14 @@ static void show_sched_info(struct chrt_ctl *ctl) { if (ctl->all_tasks) { #ifdef __linux__ + DIR *sub = NULL; pid_t tid; - struct proc_tasks *ts = proc_open_tasks(ctl->pid); + struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL); - if (!ts) - err(EXIT_FAILURE, _("cannot obtain the list of tasks")); - - while (!proc_next_tid(ts, &tid)) + while (pc && procfs_process_next_tid(pc, &sub, &tid) == 0) show_sched_pid_info(ctl, tid); - proc_close_tasks(ts); + ul_unref_path(pc); #else err(EXIT_FAILURE, _("cannot obtain the list of tasks")); #endif @@ -325,17 +323,18 @@ static void set_sched(struct chrt_ctl *ctl) { if (ctl->all_tasks) { #ifdef __linux__ + DIR *sub = NULL; pid_t tid; - struct proc_tasks *ts = proc_open_tasks(ctl->pid); + struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL); - if (!ts) + if (!pc) err(EXIT_FAILURE, _("cannot obtain the list of tasks")); - while (!proc_next_tid(ts, &tid)) + while (procfs_process_next_tid(pc, &sub, &tid) == 0) { if (set_sched_one(ctl, tid) == -1) err(EXIT_FAILURE, _("failed to set tid %d's policy"), tid); - - proc_close_tasks(ts); + } + ul_unref_path(pc); #else err(EXIT_FAILURE, _("cannot obtain the list of tasks")); #endif -- 2.47.2