Fix oom-score-adj on older distros. (#7724)

Don't assume `ps` handles `-h` to display output without headers and
manually trim headers line from output.

(cherry picked from commit b61b663895f16d9f559a14c408c225062254a57b)
This commit is contained in:
Yossi Gottlieb 2020-08-30 12:23:47 +03:00 committed by Oran Agra
parent 1b100a167a
commit f38e2802b6

View File

@ -16,8 +16,8 @@ if {$system_name eq {linux}} {
proc get_child_pid {} {
set pid [srv 0 pid]
set fd [open "|ps --ppid $pid -o pid -h" "r"]
set child_pid [string trim [read $fd]]
set fd [open "|ps --ppid $pid -o pid" "r"]
set child_pid [string trim [lindex [split [read $fd] \n] 1]]
close $fd
return $child_pid