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

Process cmdline is truncated on Solaris #694

Closed
gozdal opened this issue Oct 2, 2015 · 6 comments
Closed

Process cmdline is truncated on Solaris #694

gozdal opened this issue Oct 2, 2015 · 6 comments

Comments

@gozdal
Copy link

gozdal commented Oct 2, 2015

p.cmdline() is truncated to 80 characters on Solaris 11. /proc/PID/psinfo that psutil uses to read the command line contains only the beginning - See e.g. https://unix.stackexchange.com/questions/3934/how-can-i-get-a-full-process-list-in-solaris-without-truncated-lines.
The solution would be to use the same method as pargs tool - https://github.com/illumos/illumos-gate/blob/09f79f7c66b85f056db11f58210dc6182c9b1aef/usr/src/cmd/ptools/pargs/pargs.c. It's not however clear to me how can it be easily ported as it's using libproc, which is documented in https://github.com/illumos/illumos-gate/blob/09f79f7c66b85f056db11f58210dc6182c9b1aef/usr/src/lib/libproc/common/libproc.h as:

 * In the meantime, be aware that any program linked with libproc in this
 * release of Solaris is almost guaranteed to break in the next release.
 *
 * In short, do not use this header file or libproc for any purpose.

As a workaround cmdline() could try to launch pargs if available but it bears a fork cost.

Didn't test any other Solaris version.

@giampaolo
Copy link
Owner

I don't like parsing pargs. Instead we should figure out how pargs determines the full cmdline.

@gozdal
Copy link
Author

gozdal commented Oct 5, 2015

Me neither, but it was really a quick-fix.
I linked the source code for pargs, but it's 1500 lines of code which I couldn't even get to compile as it relies on libproc and I didn't have it installed. I guess it's possible to reimplement it.

alxchk added a commit to alxchk/psutil that referenced this issue May 19, 2017
@giampaolo giampaolo added the bug label May 19, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 19, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 19, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 20, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 20, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 20, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 21, 2017
alxchk added a commit to alxchk/psutil that referenced this issue May 21, 2017
@giampaolo
Copy link
Owner

@alxchk I think I lost track on this. Was this fixed?

@gozdal
Copy link
Author

gozdal commented Oct 10, 2017

@alxchk Care to elaborate whether your fork fixes the problem of truncated command line on Solaris?

@gsauthof
Copy link
Contributor

@gozdal , the implementation used in the fork and now included upstream should fix the truncating as the code directly reads the argv from the address-space of the running process, cf.:

https://github.com/giampaolo/psutil/blob/master/psutil/arch/solaris/environ.c#L287-L299

That means this avoids the truncating processes your user has enough permissions to look into their address space.

@gozdal
Copy link
Author

gozdal commented Apr 13, 2018

@gsauthof O, great, I guess this issue is now solved.

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

Successfully merging a pull request may close this issue.

3 participants