diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-11-09 15:25:12 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-11-09 15:25:12 +0100 |
commit | 6e170f63e4c66b0fe0b3d3bb1b1585089caf9f78 (patch) | |
tree | af6e733480bfc79eb5aa0da183c4dfd214f38079 | |
parent | f5bcc2a39f83967048d6f1963dac1139652a4e49 (diff) | |
download | psutil-6e170f63e4c66b0fe0b3d3bb1b1585089caf9f78.tar.gz |
fix pid 0 test
-rw-r--r-- | psutil/_psbsd.py | 4 | ||||
-rw-r--r-- | test/test_psutil.py | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index 3cd392a0..8b980b2d 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -348,6 +348,8 @@ class Process(object): @wrap_exceptions def cmdline(self): + if OPENBSD and self.pid == 0: + return None # ...else it crashes return cext.proc_cmdline(self.pid) @wrap_exceptions @@ -491,6 +493,8 @@ class Process(object): """Return process current working directory.""" # sometimes we get an empty string, in which case we turn # it into None + if OPENBSD and self.pid == 0: + return None # ...else raises EINVAL return cext.proc_cwd(self.pid) or None @wrap_exceptions diff --git a/test/test_psutil.py b/test/test_psutil.py index b79dc084..9ca4d175 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -2388,7 +2388,7 @@ class TestProcess(unittest.TestCase): def test_pid_0(self): # Process(0) is supposed to work on all platforms except Linux - if 0 not in psutil.pids(): + if 0 not in psutil.pids() and not OPENBSD: self.assertRaises(psutil.NoSuchProcess, psutil.Process, 0) return @@ -2429,8 +2429,11 @@ class TestProcess(unittest.TestCase): except psutil.AccessDenied: pass - self.assertIn(0, psutil.pids()) - self.assertTrue(psutil.pid_exists(0)) + p.as_dict() + + if not OPENBSD: + self.assertIn(0, psutil.pids()) + self.assertTrue(psutil.pid_exists(0)) def test_Popen(self): # Popen class test |