Skip to content

Commit

Permalink
netbsd / cwd: raise NSP on ENOENT (#2340)
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo authored Dec 19, 2023
1 parent 725e223 commit ed75c88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
*Bug tracker at https://github.com/giampaolo/psutil/issues*

5.9.8 (IN DEVELOPMENT)
======================

- 2340_, [NetBSD]: if process is terminated, `Process.cwd()`_ will return an
empty string instead of raising `NoSuchProcess`_.

5.9.7
=====

Expand Down
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
AF_LINK = _psplatform.AF_LINK

__author__ = "Giampaolo Rodola'"
__version__ = "5.9.7"
__version__ = "5.9.8"
version_info = tuple([int(num) for num in __version__.split('.')])

_timer = getattr(time, 'monotonic', time.time)
Expand Down
9 changes: 3 additions & 6 deletions psutil/arch/netbsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ psutil_proc_cwd(PyObject *self, PyObject *args) {
ssize_t len = readlink(buf, path, sizeof(path) - 1);
free(buf);
if (len == -1) {
if (errno == ENOENT) {
psutil_debug("sysctl(KERN_PROC_CWD) -> ENOENT converted to ''");
return Py_BuildValue("s", "");
}
else {
if (errno == ENOENT)
NoSuchProcess("sysctl -> ENOENT");
else
PyErr_SetFromErrno(PyExc_OSError);
}
return NULL;
}
path[len] = '\0';
Expand Down

0 comments on commit ed75c88

Please sign in to comment.