projects
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gdbsupport: make gdb_open_cloexec return scoped_fd
[binutils-gdb.git]
/
gdb
/
ser-unix.c
diff --git
a/gdb/ser-unix.c
b/gdb/ser-unix.c
index 5a9965bf744a0a67cd7c0a92a77c11b9f977d931..597032afe8967b7ccc311e75029cd66b4c7789bf 100644
(file)
--- a/
gdb/ser-unix.c
+++ b/
gdb/ser-unix.c
@@
-1,6
+1,6
@@
/* Serial interface for local (hardwired) serial ports on Un*x like systems
/* Serial interface for local (hardwired) serial ports on Un*x like systems
- Copyright (C) 1992-20
19
Free Software Foundation, Inc.
+ Copyright (C) 1992-20
21
Free Software Foundation, Inc.
This file is part of GDB.
This file is part of GDB.
@@
-26,12
+26,13
@@
#include <sys/types.h>
#include "terminal.h"
#include <sys/socket.h>
#include <sys/types.h>
#include "terminal.h"
#include <sys/socket.h>
-#include "
common
/gdb_sys_time.h"
+#include "
gdbsupport
/gdb_sys_time.h"
-#include "gdb_select.h"
+#include "gdb
support/gdb
_select.h"
#include "gdbcmd.h"
#include "gdbcmd.h"
-#include "
common
/filestuff.h"
+#include "
gdbsupport
/filestuff.h"
#include <termios.h>
#include <termios.h>
+#include "gdbsupport/scoped_ignore_sigttou.h"
struct hardwire_ttystate
{
struct hardwire_ttystate
{
@@
-40,7
+41,7
@@
struct hardwire_ttystate
#ifdef CRTSCTS
/* Boolean to explicitly enable or disable h/w flow control. */
#ifdef CRTSCTS
/* Boolean to explicitly enable or disable h/w flow control. */
-static
int
serial_hwflow;
+static
bool
serial_hwflow;
static void
show_serial_hwflow (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
static void
show_serial_hwflow (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
@@
-74,7
+75,7
@@
static int hardwire_setstopbits (struct serial *, int);
static int
hardwire_open (struct serial *scb, const char *name)
{
static int
hardwire_open (struct serial *scb, const char *name)
{
- scb->fd = gdb_open_cloexec (name, O_RDWR, 0);
+ scb->fd = gdb_open_cloexec (name, O_RDWR, 0)
.release ()
;
if (scb->fd < 0)
return -1;
if (scb->fd < 0)
return -1;
@@
-164,6
+165,9
@@
hardwire_print_tty_state (struct serial *scb,
static int
hardwire_drain_output (struct serial *scb)
{
static int
hardwire_drain_output (struct serial *scb)
{
+ /* Ignore SIGTTOU which may occur during the drain. */
+ scoped_ignore_sigttou ignore_sigttou;
+
return tcdrain (scb->fd);
}
return tcdrain (scb->fd);
}
@@
-339,31
+343,31
@@
rate_to_code (int rate)
{
/* test for perfect macth. */
if (rate == baudtab[i].rate)
{
/* test for perfect macth. */
if (rate == baudtab[i].rate)
-
return baudtab[i].code;
+ return baudtab[i].code;
else
else
-
{
+ {
/* check if it is in between valid values. */
/* check if it is in between valid values. */
-
if (rate < baudtab[i].rate)
+ if (rate < baudtab[i].rate)
{
if (i)
{
if (i)
- {
- warning (_("Invalid baud rate %d. "
+ {
+ warning (_("Invalid baud rate %d. "
"Closest values are %d and %d."),
rate, baudtab[i - 1].rate, baudtab[i].rate);
}
else
"Closest values are %d and %d."),
rate, baudtab[i - 1].rate, baudtab[i].rate);
}
else
- {
- warning (_("Invalid baud rate %d. Minimum value is %d."),
+ {
+ warning (_("Invalid baud rate %d. Minimum value is %d."),
rate, baudtab[0].rate);
}
return -1;
}
rate, baudtab[0].rate);
}
return -1;
}
-
}
+ }
}
/* The requested speed was too large. */
warning (_("Invalid baud rate %d. Maximum value is %d."),
}
/* The requested speed was too large. */
warning (_("Invalid baud rate %d. Maximum value is %d."),
-
rate, baudtab[i - 1].rate);
+ rate, baudtab[i - 1].rate);
return -1;
}
return -1;
}
@@
-376,7
+380,7
@@
hardwire_setbaudrate (struct serial *scb, int rate)
if (baud_code < 0)
{
/* The baud rate was not valid.
if (baud_code < 0)
{
/* The baud rate was not valid.
-
A warning has already been issued. */
+ A warning has already been issued. */
errno = EINVAL;
return -1;
}
errno = EINVAL;
return -1;
}
@@
-494,8
+498,9
@@
static const struct serial_ops hardwire_ops =
ser_unix_write_prim
};
ser_unix_write_prim
};
+void _initialize_ser_hardwire ();
void
void
-_initialize_ser_hardwire (
void
)
+_initialize_ser_hardwire ()
{
serial_add_interface (&hardwire_ops);
{
serial_add_interface (&hardwire_ops);