treat cygwin like linux
badboybeyer opened this issue · comments
Treat cygwin like linux, because its ps command is limited and the proc file system works.
src/shellingham/posix/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shellingham/posix/__init__.py b/src/shellingham/posix/__init__.py
index ec27b3a..1f4b80c 100644
--- a/src/shellingham/posix/__init__.py
+++ b/src/shellingham/posix/__init__.py
@@ -6,7 +6,7 @@ from .._consts import SHELL_NAMES
def _get_process_mapping():
system = platform.system()
- if system == 'Linux':
+ if system in ('Linux', 'CYGWIN_NT-6.1'):
from . import linux as impl
else:
from . import _default as impl
I think the "6.1" string may change a couple times a year. It may be better to do:
if system == 'Linux' or system.startswith('CYGWIN_NT'):
I wonder if it is a good idea to use /proc
whenever it is available. Solution is up in #5 that should work on both Linux and Cygwin, but I wonder if it would break systems such as FreeBSD. Do they all have compatible /proc
? I’ll need to find out.
It looks like the BSD4.4 children use /proc/$PID/status
instead of /proc/$PID/stat
.
Maybe write the module to:
try:
proc()
except:
ps()
Urrgh! Yeah I guess I need to revise the logic. A try-except is a good idea (but probably not a bare one).
Just handle the different structures of proc
. There are only like 3 filesystems. It’s a finite space.
Okay I think we have two. What’s the third /facepalm
I decided to
- Try /proc (detect if it is Linux and BSD styles)
- If that fails, try ps
- If ps also fails, raise an error
We can add compatibility to more uncommon formats when someone actually wants them.