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

fixing cmdline() for empty-string argumemts on posix systems #634

Merged
merged 1 commit into from Jun 18, 2015
Merged

fixing cmdline() for empty-string argumemts on posix systems #634

merged 1 commit into from Jun 18, 2015

Conversation

arnimarj
Copy link
Contributor

No description provided.

@giampaolo
Copy link
Owner

Mmmm for extra safety I would do this instead:

    @wrap_exceptions
    def cmdline(self):
        fname = "/proc/%s/cmdline" % self.pid
        kw = dict(encoding=DEFAULT_ENCODING) if PY3 else dict()
        with open(fname, "rt", **kw) as f:
            data = f.read()
        if data.endswith('\x00'):  # this should always be true
            data = data[:-1]
        return [x for x in data.split('\x00') if x]

Please change this, and also:

  • make test_psutil.py PRP8 compliant (new line are longer than 80 chars)
  • update HISTORY.rst
  • update CREDITS
    ...then it's ready to be merged.

giampaolo added a commit that referenced this pull request Jun 18, 2015
fixing cmdline() for empty-string argumemts on posix systems
@giampaolo giampaolo merged commit 02baf30 into giampaolo:master Jun 18, 2015
@giampaolo
Copy link
Owner

@arnimarj : it turns out this caused #639. I should have fixed it in 3a620d9. Can you please confirm this works as expected?

@giampaolo giampaolo added the bug label Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants