From 4e4dfc4728622d83c5d600949024449e21de868a Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 22 Nov 2024 17:44:29 +0100 Subject: [PATCH] [gdb] Add gdb::wait Add gdb::wait, and use it in gdb/procfs.c, making sure that EINTR is handled. Tested on x86_64-linux. --- gdb/procfs.c | 9 +++++---- gdbsupport/eintr.h | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index 22e012f0f31..d5177f3735d 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2062,8 +2062,9 @@ wait_again: { int wait_retval; - /* /proc file not found; presumably child has terminated. */ - wait_retval = ::wait (&wstat); /* "wait" for the child's exit. */ + /* /proc file not found; presumably child has terminated. Wait + for the child's exit. */ + wait_retval = gdb::wait (&wstat); /* Wrong child? */ if (wait_retval != inf->pid) @@ -2150,7 +2151,7 @@ wait_again: } else { - int temp = ::wait (&wstat); + int temp = gdb::wait (&wstat); /* FIXME: shouldn't I make sure I get the right event from the right process? If (for @@ -2562,7 +2563,7 @@ unconditionally_kill_inferior (procinfo *pi) ret = gdb::waitpid (pi->pid, &status, 0); #else - wait (NULL); + gdb::wait (NULL); #endif } } diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h index 1b99d1c55c5..fa2af615592 100644 --- a/gdbsupport/eintr.h +++ b/gdbsupport/eintr.h @@ -83,6 +83,12 @@ open (const char *pathname, int flags) return gdb::handle_eintr (-1, ::open, pathname, flags); } +inline pid_t +wait (int *wstatus) +{ + return gdb::handle_eintr (-1, ::wait, wstatus); +} + inline int close (int fd) {