diff options
author | Tom Tromey <tromey@adacore.com> | 2023-09-01 12:11:37 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-11-27 12:55:14 -0700 |
commit | a2e0acea420cca881296c6fcf58920f3d7c05a45 (patch) | |
tree | 54f369a7b5a2ead36e15f14e2d0d154a30286fab /gdb/ser-pipe.c | |
parent | ad3cf8c64e6e4794fc48d28c90f20cbbfdc51ca4 (diff) | |
download | gdb-a2e0acea420cca881296c6fcf58920f3d7c05a45.zip gdb-a2e0acea420cca881296c6fcf58920f3d7c05a45.tar.gz gdb-a2e0acea420cca881296c6fcf58920f3d7c05a45.tar.bz2 |
Change serial "open" functions to throw exception
remote.c assumes that a failure to open the serial connection will set
errno. This is somewhat true, because the Windows code tries to set
errno appropriately -- but only somewhat, because it isn't clear that
the "pex" code sets it, and the tcp code seems to do the wrong thing.
It seems better to simply have the serial open functions throw on
error.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770
Diffstat (limited to 'gdb/ser-pipe.c')
-rw-r--r-- | gdb/ser-pipe.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c index 47ccd33..7bdaaa0 100644 --- a/gdb/ser-pipe.c +++ b/gdb/ser-pipe.c @@ -34,7 +34,6 @@ #include <signal.h> -static int pipe_open (struct serial *scb, const char *name); static void pipe_close (struct serial *scb); struct pipe_state @@ -44,7 +43,7 @@ struct pipe_state /* Open up a raw pipe. */ -static int +static void pipe_open (struct serial *scb, const char *name) { #if !HAVE_SOCKETPAIR @@ -69,12 +68,13 @@ pipe_open (struct serial *scb, const char *name) } if (gdb_socketpair_cloexec (AF_UNIX, SOCK_STREAM, 0, pdes) < 0) - return -1; + perror_with_name (_("could not open socket pair")); if (gdb_socketpair_cloexec (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0) { + int save = errno; close (pdes[0]); close (pdes[1]); - return -1; + perror_with_name (_("could not open socket pair"), save); } /* Create the child process to run the command in. Note that the @@ -86,11 +86,12 @@ pipe_open (struct serial *scb, const char *name) /* Error. */ if (pid == -1) { + int save = errno; close (pdes[0]); close (pdes[1]); close (err_pdes[0]); close (err_pdes[1]); - return -1; + perror_with_name (_("could not vfork"), save); } if (fcntl (err_pdes[0], F_SETFL, O_NONBLOCK) == -1) @@ -148,7 +149,6 @@ pipe_open (struct serial *scb, const char *name) /* If we don't do this, GDB simply exits when the remote side dies. */ signal (SIGPIPE, SIG_IGN); - return 0; #endif } |