From 1bfe21baa32acc64f865c65ef5924b167de33439 Mon Sep 17 00:00:00 2001 From: Klemens Morgenstern Date: Sun, 7 Sep 2025 17:42:03 +0800 Subject: [PATCH] Failed pidfd_open causes an exception Closes #513. --- include/boost/process/v2/detail/process_handle_fd.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/process/v2/detail/process_handle_fd.hpp b/include/boost/process/v2/detail/process_handle_fd.hpp index bb2eb0d7..34a54669 100644 --- a/include/boost/process/v2/detail/process_handle_fd.hpp +++ b/include/boost/process/v2/detail/process_handle_fd.hpp @@ -69,6 +69,8 @@ struct basic_process_handle_fd basic_process_handle_fd(executor_type executor, pid_type pid) : pid_(pid), descriptor_(executor, syscall(SYS_pidfd_open, pid, 0)) { + if (descriptor_.native_handle() == -1) + detail::throw_error(detail::get_last_error(), "wait(pid)"); } basic_process_handle_fd(executor_type executor, pid_type pid, native_handle_type process_handle)