Skip to content

Fix error calling ps on AIX platforms#22

Open
kadler wants to merge 1 commit into
sarugaku:masterfrom
kadler:master
Open

Fix error calling ps on AIX platforms#22
kadler wants to merge 1 commit into
sarugaku:masterfrom
kadler:master

Conversation

@kadler

@kadler kadler commented Mar 14, 2019

Copy link
Copy Markdown

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

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 sarugaku#21
@uranusjr

Copy link
Copy Markdown
Member

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.

@uranusjr

Copy link
Copy Markdown
Member

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?

@kadler

kadler commented Mar 14, 2019

Copy link
Copy Markdown
Author

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.

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 :(

@kadler

kadler commented Mar 14, 2019

Copy link
Copy Markdown
Author

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.

@uranusjr

Copy link
Copy Markdown
Member

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).

@kadler

kadler commented Mar 14, 2019

Copy link
Copy Markdown
Author

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

@uranusjr

Copy link
Copy Markdown
Member

Ah, excellent. I’ll try to implement a parser for that format. Thanks for the help!

@uranusjr

Copy link
Copy Markdown
Member

I just realised switching to ps wwl would likely affect #15. @sirn could you try the command out and see whether

  1. ps prints a header row (but no actual content), and
  2. the command returns 0?

@sirn

sirn commented Mar 15, 2019

Copy link
Copy Markdown

From what I tried,

  1. ✅ The command returns header row without content
  2. ❌ 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

@kdeldycke

Copy link
Copy Markdown

@kadler , if you still have access to an AIX machine, you can run uvx extra-platforms and check the detection results. I just added heuristics for this in Extra Platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect_shell fails on IBM i / AIX

4 participants