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

Fix error calling ps on AIX platforms #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kadler
Copy link

@kadler kadler commented Mar 14, 2019

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
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
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
Copy link
Author

kadler commented Mar 14, 2019

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
Copy link
Author

kadler commented Mar 14, 2019

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
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
Copy link
Author

kadler commented Mar 14, 2019

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
Member

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

@uranusjr
Copy link
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
Copy link

sirn commented Mar 15, 2019

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

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.

3 participants