Skip to content

Commit

Permalink
Merge pull request #5 from sarugaku/use-proc-if-theres-proc
Browse files Browse the repository at this point in the history
Revise process logic selection
  • Loading branch information
uranusjr authored Jul 4, 2018
2 parents 9b19dfe + d4e9234 commit 1d6c08e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/shellingham/posix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
import platform

from .._consts import SHELL_NAMES


def _get_process_mapping():
system = platform.system()
if system == 'Linux':
from . import linux as impl
"""Select a way to obtain process information from the system.
* `/proc` is used if supported.
* The system `ps` utility is used as a fallback option.
"""
if os.path.isdir('/proc') and os.listdir('/proc'):
# Need to check if /proc contains stuff. It might not be mounted.
from . import _proc as impl
else:
from . import _default as impl
from . import _ps as impl
return impl.get_process_mapping()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def get_process_mapping():
"""Try to look up the process tree via Linux's /proc
"""Try to look up the process tree via the /proc interface.
"""
with open('/proc/{0}/stat'.format(os.getpid())) as f:
self_tty = f.read().split()[STAT_TTY]
Expand Down
File renamed without changes.

0 comments on commit 1d6c08e

Please sign in to comment.