1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-10 13:23:41 +00:00

Fixed init.d PID check

This commit is contained in:
Bryan Roe
2020-09-10 10:49:26 -07:00
parent 0f042fa34e
commit 61b8c71e6a
2 changed files with 19 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1327,7 +1327,22 @@ function serviceManager()
}
else
{
child.stdin.write("service " + this.name + " status | awk '{print $NF}'\nexit\n");
child.stdin.write("service " + this.name + " status | awk '");
child.stdin.write('{');
child.stdin.write(' sh=sprintf("ps -e -o pid -o ppid | grep %s", $NF);');
child.stdin.write(' shval=system(sh);');
child.stdin.write("}'");
child.stdin.write(' | tr ' + "'\\n' '`' | awk -F'`' '");
child.stdin.write('{');
child.stdin.write(' root="";');
child.stdin.write(' pid="";');
child.stdin.write(' for(n=1;n<NF;++n)');
child.stdin.write(' {');
child.stdin.write(' split($n, i, " ");');
child.stdin.write(' if(i[2]=="1") { root=i[1]; } else { pid=i[1]; }');
child.stdin.write(' }');
child.stdin.write(' printf("%s", pid==""?root:pid);');
child.stdin.write("}'\nexit\n");
}
child.waitExit();
return (parseInt(child.stdout.str.trim()) == process.pid);