Only run ps -ww -p $PID -o command= if available

This commit is contained in:
Sumanth Ratna 2020-12-20 17:26:32 -05:00 committed by Qix
parent 7b41752775
commit 249bc245b9

View File

@ -161,12 +161,17 @@ class ExceptionFormatter(object):
pass pass
if cmdline is None and os.name == 'posix': if cmdline is None and os.name == 'posix':
from shutil import which
if which('ps'):
from subprocess import CalledProcessError, check_output as spawn from subprocess import CalledProcessError, check_output as spawn
try: try:
cmdline = spawn(['ps', '-ww', '-p', str(os.getpid()), '-o', 'command=']) cmdline = spawn(['ps', '-ww', '-p', str(os.getpid()), '-o', 'command='])
except CalledProcessError: except CalledProcessError:
return '' return ''
else:
return ''
else: else:
# current system doesn't have a way to get the command line # current system doesn't have a way to get the command line
return '' return ''