pmb.helpers.run_core.kill_commands: use minimal subset of ps parameters (MR 2074)
again, busybox ps supports only -o option (-e is ignored, because busybox always shows all processes).
This commit is contained in:
parent
31e7a0006d
commit
1bb15765ed
|
@ -110,10 +110,10 @@ def kill_command(args, pid, sudo):
|
|||
:param pid: process id that will be killed
|
||||
:param sudo: use sudo to kill the process
|
||||
"""
|
||||
cmd = ["ps", "-e", "-o", "pid=,ppid=", "--noheaders"]
|
||||
cmd = ["ps", "-e", "-o", "pid,ppid"]
|
||||
ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE)
|
||||
ppids = []
|
||||
proc_entries = ret.stdout.decode("utf-8").rstrip().split('\n')
|
||||
proc_entries = ret.stdout.decode("utf-8").rstrip().split('\n')[1:]
|
||||
for row in proc_entries:
|
||||
items = row.split()
|
||||
if len(items) != 2:
|
||||
|
|
|
@ -98,16 +98,16 @@ def test_foreground_pipe(args):
|
|||
# The first command uses ps to get its process group id (pgid) and echo it
|
||||
# to stdout. All of the test commands will be running under that pgid.
|
||||
cmd = ["sudo", "sh", "-c",
|
||||
"pgid=$(ps -p ${1:-$$} -o pgid=);echo $pgid | tr -d '\n';" +
|
||||
"pgid=$(ps -o pgid= | grep ^${1:-$$});echo $pgid | tr -d '\n';" +
|
||||
"sleep 10 | sleep 20 | sleep 30"]
|
||||
args.timeout = 0.3
|
||||
ret = func(args, cmd, output_return=True, output_timeout=True,
|
||||
sudo=True)
|
||||
pgid = str(ret[1])
|
||||
|
||||
cmd = ["ps", "-e", "-o", "pgid=,comm=", "--noheaders"]
|
||||
cmd = ["ps", "-e", "-o", "pgid,comm"]
|
||||
ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE)
|
||||
procs = str(ret.stdout.decode("utf-8")).rstrip().split('\n')
|
||||
procs = str(ret.stdout.decode("utf-8")).rstrip().split('\n')[1:]
|
||||
child_procs = []
|
||||
for process in procs:
|
||||
items = process.split(maxsplit=1)
|
||||
|
|
Loading…
Reference in New Issue