Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise process logic selection #5

Merged
merged 2 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.