public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Hannes Domani <ssbssa@yahoo.de>
Cc: Tom Tromey <tromey@adacore.com>,
	 "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/3] Fix control-c handling on Windows
Date: Fri, 09 Dec 2022 10:20:52 -0700	[thread overview]
Message-ID: <87edt8ijd7.fsf@tromey.com> (raw)
In-Reply-To: <1095715284.5500968.1670602756752@mail.yahoo.com> (Hannes Domani's message of "Fri, 9 Dec 2022 16:19:16 +0000 (UTC)")

>> If that's the issue then I can write a patch to change sigint_ours to be
>> a gdb::optional and check it that way.

Hannes> I should have been more clear about this.
Hannes> I started with 'new-console on', so sharing_input_terminal() returned false,
Hannes> and that's why sigint_ours was not set.

Hannes> So yes, gdb::optional would probably fix this.
Hannes> I just wonder if this is never an issue on Linux, e.g. if you attach,
Hannes> of does signal() maybe ignore NULL-pointer functions?

Normally SIG_DFL is NULL, but also on Linux I couldn't get this to
trigger inappropriately.  Maybe my theory about what's going on here is
incorrect.

Hannes> As far as I could tell, signal() calls SetConsoleCtrlHandler(), probably
Hannes> similar to how you handled this.

Yeah, that was my guess as well, but really we'd want more details.
Like, does calling signal reinstall the SetConsoleCtrlHandler?  If so
then why didn't that work for gdb?  But if not then why did we need to
call SetConsoleCtrlHandler again to tweak the ordering of callbacks?

Maybe I should go back and try to figure out what else is calling signal
and/or SetConsoleCtrlHandler.  I somewhat suspect Python but I don't
really know.

>> I did try 'new-console on' with my (x86-64) build, and that worked fine.
>> I can try an x86 build and see if that works any better.

Hannes> Again, I wasn't clear enough here.
Hannes> The difference is not because of i686 and x86_64, but that the x86_64 build
Hannes> has TUI+python enabled, but my i686 build has not.

Aha, I see, thanks.

Hannes> Some TUI startup code would later call install_sigint_handler() again,
Hannes> overriding the SIGINT handler again, and everything is fine.

Do you know where this happens?

Anyway I am wondering if we can have gdb_rl_deprep_term_function call
rl_clear_signals and then reinstall the gdb signal handlers.  This idea
makes me wonder if we even need SetConsoleCtrlHandler at all -- maybe gdb
could just use signal after all.

Tom

  reply	other threads:[~2022-12-09 17:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 18:56 [PATCH 0/3] Fix Windows C-c handling Tom Tromey
2022-12-05 18:56 ` [PATCH 1/3] Rename install_sigint_handler Tom Tromey
2022-12-05 18:56 ` [PATCH 2/3] Refactor code to check for terminal sharing Tom Tromey
2022-12-05 19:50   ` Eli Zaretskii
2022-12-12 17:27     ` Tom Tromey
2022-12-05 18:56 ` [PATCH 3/3] Fix control-c handling on Windows Tom Tromey
2022-12-07 17:13   ` Hannes Domani
2022-12-09 15:58     ` Tom Tromey
2022-12-09 16:19       ` Hannes Domani
2022-12-09 17:20         ` Tom Tromey [this message]
2022-12-09 18:13           ` Hannes Domani
2022-12-12 15:36             ` Tom Tromey
2022-12-12 17:05               ` Tom Tromey
2022-12-13 11:30                 ` Hannes Domani
2022-12-13 19:51                   ` Tom Tromey
2022-12-05 18:59 ` [PATCH 0/3] Fix Windows C-c handling Tom Tromey
2022-12-12 13:23   ` Jon Turney
2022-12-12 17:29     ` 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=87edt8ijd7.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /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).