shellingham
shellingham copied to clipboard
Fix error calling ps on AIX platforms
AIX ps does not support -w option in POSIX mode, only in Berkeley mode ('w'), but Berkeley mode doesn't support -o, so just remove the -ww option and hope for the best.
Fixes #21
Do you have the man
entry available? I wonder if there are other flags we can use to keep w
. That helps with some edge cases.
Also, is it possible to sniff out IBM systems in Python? Do os.name
, sys.platform
, or various calls from the platform
module return interesting information?
Do you have the
man
entry available? I wonder if there are other flags we can use to keepw
. That helps with some edge cases.
The latest man page is here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm
I did not see an equivalent option for -w
in POSIX mode or -o
in Berkeley mode, unfortuantely :(
On AIX, os.name
is 'posix', sys.platform
is 'aix' followed by the major version (ie. 'aix6', 'aix7', ...).
We also run a variant of AIX inside of the IBM i OS. There, sys.platform
will return 'os400' followed by the major version. I've included those platform checks in this PR.
The latest man page is here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm
I did not see an equivalent option for -w in POSIX mode or -o in Berkeley mode, unfortuantely :(
Does ps wwl
work? That would contain all the information we need (although more difficult to parse than -o
).
Yes, here's a sample:
-bash-4.4$ ps wwl
F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
240000 A 105 897903 897902 0 20 20 0 7124 0 pts/0 0:00 -bash
200000 A 105 897904 897903 0 20 20 0 6792 0 pts/0 0:00 ps wwl
Ah, excellent. I’ll try to implement a parser for that format. Thanks for the help!
I just realised switching to ps wwl
would likely affect #15. @sirn could you try the command out and see whether
-
ps
prints a header row (but no actual content), and - the command returns 0?
From what I tried,
- ✅ The command returns header row without content
- ❌ The command returns 0
~ $ ssh freebsd.gemini 'uname -a'
FreeBSD freebsd 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64
~ $ ssh freebsd.gemini 'ps wwl || echo $?'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
1