From: Simon Marchi <simon.marchi@polymtl.ca>
To: paul@mad-scientist.net
Cc: gdb@sourceware.org
Subject: Re: GDB (not) handling SIGINT...?
Date: Wed, 14 Nov 2018 22:32:00 -0000 [thread overview]
Message-ID: <17a7ce8aa190956bd7a8ba9bd7cdea16@polymtl.ca> (raw)
In-Reply-To: <8003dfcd98e9a4d1e43f53220e0d446669944ead.camel@mad-scientist.net>
On 2018-11-13 17:37, Paul Smith wrote:
> Hi all; I'm using GDB 8.1 on a modern 64bit GNU/Linux system (Ubuntu
> 18.04LTS).
>
> Recently I added a call to sigtimedwait() for SIGINT into my
> (multithreaded) program and now I'm having an issue with GDB.
>
> What I want is that if I attach to my program then continue, then use
> ^C at the GDB terminal, I should get a (gdb) prompt back but I do NOT
> want the SIGINT delivered to my program to wake up my sigtimedwait()
> call (because it will cause my program to do various things that I
> don't want it to do).
>
> I see that SIGINT is set to nopass:
>
> (gdb) info signals SIGINT
> Signal Stop Print Pass to program Description
> SIGINT Yes Yes No Interrupt
>
> but yet when I use ^C at the GDB prompt my sigtimedwait() call inside
> my program does return with "2" (SIGINT), which I don't want.
>
> I guess I don't understand what the docs mean when they say that the
> signal is not passed to the process under debug. Note that in my case
> I'm attaching to the program from a completely different terminal so
> there's no issue with process groups etc. and as far as I can
> understand it, the signal should only be delivered to GDB not my
> process, so unless there's some weird magic at work here it must be GDB
> forwarding that signal to my process.
>
> Anyone have any thoughts about this?
>
> Cheers!
I was able to reproduce it with, it really sounds like a bug.
If others want to try, here's my test program:
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
int main()
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGINT);
sigprocmask(SIG_BLOCK, &set, NULL);
for (int i = 0; i < 10; i++) {
int n = sigwaitinfo(&set, NULL);
printf("signal %d\n", n);
}
}
Run in a terminal, attach with GDB in another terminal, continue, then
ctrl-C in GDB's terminal. The first call to sigwaitinfo returns -1, I
think it's expected as the syscall gets interrupted. But the subsequent
calls return 2, showing that indeed the process has received a SIGINT.
Paul, could you please file a bug? You can re-use this test program if
you want.
Simon
next prev parent reply other threads:[~2018-11-14 22:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 22:37 Paul Smith
2018-11-14 22:32 ` Simon Marchi [this message]
2018-11-15 13:55 ` Pedro Alves
2018-11-15 16:01 ` Paul Smith
2018-11-15 16:24 ` Pedro Alves
2018-11-15 18:01 ` Paul Smith
2018-11-15 18:04 ` Pedro Alves
2018-11-15 18:27 ` Paul Smith
2018-11-19 19:07 ` Paul Smith
2018-11-19 19:44 ` Paul Smith
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=17a7ce8aa190956bd7a8ba9bd7cdea16@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb@sourceware.org \
--cc=paul@mad-scientist.net \
/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