Returns list of tuples (pid, command) of processes running in the same out directory as this checkout.
()
| 17 | |
| 18 | |
| 19 | def list_processes_linux(): |
| 20 | """Returns list of tuples (pid, command) of processes running in the same out |
| 21 | directory as this checkout. |
| 22 | """ |
| 23 | if platform.system() != 'Linux': |
| 24 | return [] |
| 25 | try: |
| 26 | cmd = 'pgrep -fa %s' % OUT_DIR |
| 27 | output = subprocess.check_output(cmd, shell=True, text=True) or '' |
| 28 | processes = [ |
| 29 | (int(line.split()[0]), line[line.index(OUT_DIR):]) |
| 30 | for line in output.splitlines() |
| 31 | ] |
| 32 | # Filter strange process with name as out dir. |
| 33 | return [p for p in processes if p[1] != OUT_DIR] |
| 34 | except subprocess.CalledProcessError as e: |
| 35 | # Return code 1 means no processes found. |
| 36 | if e.returncode != 1: |
| 37 | # TODO(https://crbug.com/v8/13101): Remove after investigation. |
| 38 | logging.exception('Fetching process list failed.') |
| 39 | return [] |
| 40 | |
| 41 | |
| 42 | def kill_processes_linux(): |
no test coverage detected
searching dependent graphs…