Skip to content

Commit

Permalink
PyErr_Clear();
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 14, 2024
1 parent 3175f19 commit f8b929b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions psutil/arch/bsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
psutil_debug(
"open_files() returned ESRCH for PID 0; forcing `return []`"
);
PyErr_Clear();
return py_retlist;
}
#else
Expand Down
2 changes: 2 additions & 0 deletions psutil/arch/openbsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) {
return NULL;

freep = kinfo_getfile(pid, &cnt);

if (freep == NULL) {
#if defined(PSUTIL_OPENBSD)
if ((pid == 0) && (errno == ESRCH)) {
psutil_debug(
"num_fds() returned ESRCH for PID 0; forcing `return 0`"
);
PyErr_Clear();
return Py_BuildValue("i", 0);
}
#endif
Expand Down

0 comments on commit f8b929b

Please sign in to comment.