Skip to content

Commit

Permalink
#639: (Linux) proc cmdline can be truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jul 9, 2015
1 parent 9c49cd1 commit 3a620d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Expand Up @@ -9,6 +9,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
incomplete list of connnections.
- #637: [UNIX] raise exception if trying to send signal to Process PID 0 as it
will affect os.getpid()'s process group instead of PID 0.
- #639: [Linux] Process.cmdline() can be truncated.

3.0.1 - 2015-06-18
Expand Down
5 changes: 4 additions & 1 deletion psutil/_pslinux.py
Expand Up @@ -783,7 +783,10 @@ 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:
return [x for x in f.read()[:-1].split('\x00')]
data = f.read()
if data.endswith('\x00'):
data = data[:-1]
return [x for x in data.split('\x00')]

@wrap_exceptions
def terminal(self):
Expand Down

0 comments on commit 3a620d9

Please sign in to comment.