From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH v2 2/4] Use gdb::optional for sigint_ours
Date: Mon, 12 Dec 2022 11:11:11 -0700 [thread overview]
Message-ID: <20221212181113.1501286-3-tromey@adacore.com> (raw)
In-Reply-To: <20221212181113.1501286-1-tromey@adacore.com>
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.
---
gdb/inflow.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 5477624bcd5..da2005a9318 100644
--- a/gdb/inflow.c
+++ b/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
to SIG_IGN. */
-static sighandler_t sigint_ours;
+static gdb::optional<sighandler_t> sigint_ours;
#ifdef SIGQUIT
-static sighandler_t sigquit_ours;
+static gdb::optional<sighandler_t> sigquit_ours;
#endif
/* 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)
{
- signal (SIGINT, sigint_ours);
+ if (sigint_ours.has_value ())
+ signal (SIGINT, *sigint_ours);
+ sigint_ours.reset ();
#ifdef SIGQUIT
- signal (SIGQUIT, sigquit_ours);
+ if (sigquit_ours.has_value ())
+ signal (SIGQUIT, *sigquit_ours);
+ sigquit_ours.reset ();
#endif
}
--
2.34.3
next prev parent reply other threads:[~2022-12-12 18:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 18:11 [PATCH v2 0/4] Fix Windows C-c handling Tom Tromey
2022-12-12 18:11 ` [PATCH v2 1/4] Rename install_sigint_handler Tom Tromey
2022-12-12 18:11 ` Tom Tromey [this message]
2022-12-12 18:11 ` [PATCH v2 3/4] Refactor code to check for terminal sharing Tom Tromey
2022-12-12 18:11 ` [PATCH v2 4/4] Fix control-c handling on Windows Tom Tromey
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=20221212181113.1501286-3-tromey@adacore.com \
--to=tromey@adacore.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).