From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] [gdbsupport] Add gdb::wait
Date: Mon, 28 Oct 2024 18:49:13 +0100 [thread overview]
Message-ID: <20241028174913.27056-3-tdevries@suse.de> (raw)
In-Reply-To: <20241028174913.27056-1-tdevries@suse.de>
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.cc | 6 ++++++
gdbsupport/eintr.h | 2 ++
3 files changed, 13 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 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
{
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 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
}
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.cc b/gdbsupport/eintr.cc
index 7e24fa56224..cb6e45feb3c 100644
--- a/gdbsupport/eintr.cc
+++ b/gdbsupport/eintr.cc
@@ -33,6 +33,12 @@ extern "C" {
return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options);
}
+ pid_t
+ wait (int *wstatus)
+ {
+ return gdb::handle_eintr (-1, ::wait, wstatus);
+ }
+
int
open (const char *pathname, int flags)
{
diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h
index 3919c9fd930..286da5fc400 100644
--- a/gdbsupport/eintr.h
+++ b/gdbsupport/eintr.h
@@ -68,6 +68,8 @@ handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
extern "C" {
extern pid_t waitpid (pid_t pid, int *wstatus, int options);
+ extern pid_t wait (int *wstatus);
+
extern int open (const char *pathname, int flags);
extern int close (int fd);
extern ssize_t read (int fd, void *buf, size_t count);
--
2.35.3
next prev parent reply other threads:[~2024-10-28 17:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 17:49 [PATCH 1/3] [gdbsupport] Add gdb::{waitpid,read,write,close} Tom de Vries
2024-10-28 17:49 ` [PATCH 2/3] [gdb] Use gdb::waitpid more often Tom de Vries
2024-10-28 17:49 ` Tom de Vries [this message]
2024-11-01 17:35 ` [PATCH 1/3] [gdbsupport] Add gdb::{waitpid,read,write,close} Tom Tromey
2024-11-05 12:07 ` Tom de Vries
2024-11-22 16:46 ` Tom de Vries
2024-11-29 16:15 ` Simon Marchi
2024-11-29 16:23 ` Tom de Vries
2024-11-29 16:27 ` Simon Marchi
2024-11-29 16:32 ` Tom de Vries
2024-11-29 17:23 ` Simon Marchi
2024-11-29 17:28 ` Tom de Vries
2024-12-02 9:38 ` Kévin Le Gouguec
2024-12-02 11:07 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028174913.27056-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox