mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 16:53:50 +08:00
Use gdb::optional for sigint_ours
sigint_ours (and sigquit_ours) can be used without being set. Avoid this problem by changing them to gdb::optional and checking that they are in fact set before using the value.
This commit is contained in:
12
gdb/inflow.c
12
gdb/inflow.c
@ -113,9 +113,9 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *);
|
|||||||
we save our handlers in these two variables and set SIGINT and SIGQUIT
|
we save our handlers in these two variables and set SIGINT and SIGQUIT
|
||||||
to SIG_IGN. */
|
to SIG_IGN. */
|
||||||
|
|
||||||
static sighandler_t sigint_ours;
|
static gdb::optional<sighandler_t> sigint_ours;
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
static sighandler_t sigquit_ours;
|
static gdb::optional<sighandler_t> sigquit_ours;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The name of the tty (from the `tty' command) that we're giving to
|
/* The name of the tty (from the `tty' command) that we're giving to
|
||||||
@ -501,9 +501,13 @@ child_terminal_ours_1 (target_terminal_state desired_state)
|
|||||||
|
|
||||||
if (!job_control && desired_state == target_terminal_state::is_ours)
|
if (!job_control && desired_state == target_terminal_state::is_ours)
|
||||||
{
|
{
|
||||||
signal (SIGINT, sigint_ours);
|
if (sigint_ours.has_value ())
|
||||||
|
signal (SIGINT, *sigint_ours);
|
||||||
|
sigint_ours.reset ();
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
signal (SIGQUIT, sigquit_ours);
|
if (sigquit_ours.has_value ())
|
||||||
|
signal (SIGQUIT, *sigquit_ours);
|
||||||
|
sigquit_ours.reset ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user