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

[NetBSD] cmdline() raise ZombieProcess when unable to decode chars #1536

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ XXXX-XX-XX
(patch by Arnon Yaari)
- 1535_: 'type' and 'family' fields returned by net_connections() are not
always turned into enums.
- 1536_: [NetBSD] process cmdline() erroneously raise ZombieProcess error if
cmdline has non encodable chars.

5.6.3
=====
Expand Down
7 changes: 3 additions & 4 deletions psutil/_psbsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,9 @@ def cmdline(self):
return cext.proc_cmdline(self.pid)
except OSError as err:
if err.errno == errno.EINVAL:
if not pid_exists(self.pid):
raise NoSuchProcess(self.pid, self._name)
else:
raise ZombieProcess(self.pid, self._name, self._ppid)
# XXX: this happens with unicode tests. It means the C
# routine is unable to decode invalid unicode chars.
return []
else:
raise
else:
Expand Down
5 changes: 4 additions & 1 deletion psutil/arch/netbsd/specific.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ psutil_proc_cwd(PyObject *self, PyObject *args) {
ssize_t len = readlink(buf, path, sizeof(path) - 1);
free(buf);
if (len == -1) {
PyErr_SetFromErrno(PyExc_OSError);
if (errno == ENOENT)
NoSuchProcess("");
else
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
path[len] = '\0';
Expand Down