diff options
author | Tom de Vries <tdevries@suse.de> | 2024-11-22 17:44:29 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-11-22 17:44:29 +0100 |
commit | 658a03e9e85698fa8815915d1a858371ea51da83 (patch) | |
tree | 902c3dec08c0ece2695f535c565eefbb8da790d3 /gdb/cli | |
parent | 26522e34802f32406eb653d91a3bbb509f919b30 (diff) | |
download | binutils-658a03e9e85698fa8815915d1a858371ea51da83.zip binutils-658a03e9e85698fa8815915d1a858371ea51da83.tar.gz binutils-658a03e9e85698fa8815915d1a858371ea51da83.tar.bz2 |
[gdbsupport] Add gdb::{waitpid,read,write,close}
We have gdb::handle_eintr, which allows us to rewrite:
...
ssize_t ret;
do
{
errno = 0;
ret = ::write (pipe[1], "+", 1);
}
while (ret == -1 && errno == EINTR);
...
into:
...
ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
...
However, the call to write got a bit mangled, requiring effort to decode it
back to its original form.
Instead, add a new function gdb::write that allows us to write:
...
ssize_t ret = gdb::write (pipe[1], "+", 1);
...
Likewise for waitpid, read and close.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index bc6cb58..0140c71 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -923,7 +923,7 @@ run_under_shell (const char *arg, int from_tty) if (pid != -1) { - int ret = gdb::handle_eintr (-1, ::waitpid, pid, &status, 0); + int ret = gdb::waitpid (pid, &status, 0); if (ret == -1) perror_with_name ("Cannot get status of shell command"); } |