Skip to content

Commit

Permalink
Suppress error if ps output is empty
Browse files Browse the repository at this point in the history
Fix #15.
  • Loading branch information
uranusjr committed Oct 15, 2018
1 parent e5bf6bc commit 4f219da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/shellingham/posix/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def get_process_mapping():
if e.errno != errno.ENOENT:
raise
raise PsNotAvailable('ps not found')
except subprocess.CalledProcessError as e:
# `ps` can return 1 if the process list is completely empty.
# (sarugaku/shellingham#15)
if not e.output.strip():
return {}
raise
if not isinstance(output, str):
encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
output = output.decode(encoding)
Expand Down

0 comments on commit 4f219da

Please sign in to comment.