netifd: add missing error checks to packet steering script
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
a9e22ffa50
commit
123282d9f9
1 changed files with 6 additions and 1 deletions
|
@ -27,6 +27,8 @@ for (let arg in ARGV) {
|
||||||
function task_name(pid)
|
function task_name(pid)
|
||||||
{
|
{
|
||||||
let stat = open(`/proc/${pid}/status`, "r");
|
let stat = open(`/proc/${pid}/status`, "r");
|
||||||
|
if (!stat)
|
||||||
|
return;
|
||||||
let line = stat.read("line");
|
let line = stat.read("line");
|
||||||
stat.close();
|
stat.close();
|
||||||
return trim(split(line, "\t", 2)[1]);
|
return trim(split(line, "\t", 2)[1]);
|
||||||
|
@ -35,8 +37,11 @@ function task_name(pid)
|
||||||
function set_task_cpu(pid, cpu) {
|
function set_task_cpu(pid, cpu) {
|
||||||
if (disable)
|
if (disable)
|
||||||
cpu = join(",", map(cpus, (cpu) => cpu.id));
|
cpu = join(",", map(cpus, (cpu) => cpu.id));
|
||||||
|
let name = task_name(pid);
|
||||||
|
if (!name)
|
||||||
|
return;
|
||||||
if (debug || do_nothing)
|
if (debug || do_nothing)
|
||||||
warn(`taskset -p -c ${cpu} ${task_name(pid)}\n`);
|
warn(`taskset -p -c ${cpu} ${name}\n`);
|
||||||
if (!do_nothing)
|
if (!do_nothing)
|
||||||
system(`taskset -p -c ${cpu} ${pid}`);
|
system(`taskset -p -c ${cpu} ${pid}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue