[Bugme-janitors] [Bug 9039] New: GDB is not trapping SIGINT. Ctrl+C
terminates program when should break gdb.
bugme-daemon at bugzilla.kernel.org
bugme-daemon at bugzilla.kernel.org
Wed Sep 19 02:40:49 PDT 2007
http://bugzilla.kernel.org/show_bug.cgi?id=9039
Summary: GDB is not trapping SIGINT. Ctrl+C terminates program
when should break gdb.
Product: Process Management
Version: 2.5
KernelVersion: 2.6.20.1 #3 PREEMPT
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: high
Priority: P1
Component: Other
AssignedTo: process_other at kernel-bugs.osdl.org
ReportedBy: jordiblasi at gmail.com
Most recent kernel where this bug did not occur: do not know.
-----------------------------------------------
Distribution: Mandriva Powerpack 2007.
-------------
Hardware Environment: i686
---------------------
Software Environment:
---------------------
gcc (GCC) 4.1.1 20060724 (prerelease) (4.1.1-3mdk)
GNU gdb 6.5
Problem Description: GDB is not trapping SIGINT.
--------------------
I'm having problems getting GDB to not pass SIGINT to my program. In my main
thread I do a sigwait for SIGINT. When I'm debugging, while gdb is running I
may want to break gdb to set breakpoints or so, then I Ctrl-C (send SIGINT) but
gdb does not break, instead SIGINT is passed to my program that gracefully
terminates and gdb prints "Program exited normally". Of course "info handle"
shows that SIGINT should not be being passed to my program:
(gdb) info handle SIGINT
Signal Stop Print Pass to program Description
SIGINT Yes Yes No Interrupt
Gdb does not even print SIGINT signal delivery when I think it should.
At first I thought that was a gdb related problem but
http://sourceware.org/ml/gdb/2006-04/msg00010.html points to a kernel issue.
Steps to reproduce: compile and run under gdb, then hit Ctrl+C
-------------------
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
//-----------------------------------------------------------------------------
void user_catched_sighandler_term(int signal_number)
{}
//-----------------------------------------------------------------------------
void user_catched_sighandler_int(int signal_number)
{}
// Signal number, signal handler relationship
//-----------------------------------------------------------------------------
static const struct
{
int m_SigNum;
void (*m_SigHandler)(int);
}
Signal_handlers[] = {
{ SIGTERM, user_catched_sighandler_term },
{ SIGINT, user_catched_sighandler_int },
};
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
sigset_t signal_set;
int signal;
struct sigaction s;
s.sa_flags = SA_RESTART;
//! Set signal handlers
//!--------------------------------------------------------------------
for(uint sig = 0; sig < sizeof(Signal_handlers)/sizeof(Signal_handlers[0]);
sig++)
{
s.sa_handler = Signal_handlers[sig].m_SigHandler;
if(sigaction(Signal_handlers[sig].m_SigNum, &s, NULL) < 0)
{
perror("<%s> Error sigaction: ");
exit(2);
}
}
if(sigfillset(&signal_set) < 0)
{
perror("<main> Error sigfillset(): ");
exit(2);
}
while(true)
{
//! Wait for queued signals.
//!--------------------------------------------------------------------
if(sigwait(&signal_set,&signal) != 0)
{
perror("<main> Error sigwait(): ");
exit(1);
}
//! Process signal.
//!--------------------------------------------------------------------
switch(signal)
{
case SIGTERM:
case SIGINT:
printf("Terminating.\n");
exit(0);
break;
default:
printf("Unhandled signal [%s]\n",strsignal(signal));
break;
}
}
}
--
Configure bugmail: http://bugzilla.kernel.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Bugme-janitors
mailing list