diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2015-06-18 03:42:50 +0200 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2015-06-18 03:42:50 +0200 |
commit | 02baf30d1ccbb963821fb6f80addc2f3cc00acfd (patch) | |
tree | 3d78cb150d0ae66bded67681f8b31e791c8fe675 | |
parent | b2a447dbb1f886343c20263829659f29354ec123 (diff) | |
parent | 661e22dfce9ee66cba41dd46159d5ac8742bf6a5 (diff) | |
download | psutil-02baf30d1ccbb963821fb6f80addc2f3cc00acfd.tar.gz |
Merge pull request #634 from arnimarj/master
fixing cmdline() for empty-string argumemts on posix systems
-rw-r--r-- | psutil/_pslinux.py | 2 | ||||
-rw-r--r-- | test/test_psutil.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index db96776a..a0a4d350 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -775,7 +775,7 @@ class Process(object): 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().split('\x00') if x] + return [x for x in f.read()[:-1].split('\x00')] @wrap_exceptions def terminal(self): diff --git a/test/test_psutil.py b/test/test_psutil.py index 50749c46..14b5187e 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -1558,13 +1558,13 @@ class TestProcess(unittest.TestCase): with open(c_file, "w") as f: f.write("void main() { pause(); }") subprocess.check_call(["gcc", c_file, "-o", funky_name]) - sproc = get_test_subprocess([funky_name, "arg1", "arg2"]) + sproc = get_test_subprocess([funky_name, "arg1", "arg2", "", "arg3", ""]) p = psutil.Process(sproc.pid) # ...in order to try to prevent occasional failures on travis wait_for_pid(p.pid) self.assertEqual(p.name(), "foo bar )") self.assertEqual(p.exe(), "/tmp/foo bar )") - self.assertEqual(p.cmdline(), ["/tmp/foo bar )", "arg1", "arg2"]) + self.assertEqual(p.cmdline(), ["/tmp/foo bar )", "arg1", "arg2", "", "arg3", ""]) @unittest.skipUnless(POSIX, 'posix only') def test_uids(self): |