Raw PermissionError from psutil child walk bypasses _safe_children fallback
Summary
sky.utils.subprocess_utils._safe_children() catches psutil.AccessDenied and falls back to the resilient /proc walk added in #9806. Some Ray-vendored psutil builds instead let the underlying raw PermissionError escape while building the global PID-to-PPID map. That bypasses the fallback and can fail managed jobs during process cleanup.
Observed failure
A managed job failed before its task emitted output:
run_with_log
-> subprocess_utils.kill_process_daemon(proc.pid)
-> _safe_children(process)
-> process.children(recursive=True)
-> ray/thirdparty_files/psutil/_pslinux.py ppid_map
PermissionError: [Errno 13] Permission denied: /proc/2688/statThe failure is intermittent and node-dependent because it requires an unreadable process in the pod PID namespace. In the observed batch, 1 of 30 jobs failed while other jobs using the same image succeeded.
Expected behavior
A raw PermissionError from process.children(recursive=True) should take the same existing fallback path as psutil.AccessDenied. The warning should preserve the denied path for diagnostics.
Proposed fix
Catch (psutil.AccessDenied, PermissionError) in _safe_children(), log PermissionError.filename when present, and add a regression test proving the fallback runs.
Relationship to existing work
#9806 added the tolerant /proc fallback but its entry condition currently handles only psutil.AccessDenied; this issue covers the raw built-in exception variant.
Source: skypilot-org/skypilot