Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jaimon Jose <jjaimon@Yahoo.com>
To: gdb@sourceware.org
Subject: pthread_sigmask and gdb
Date: Mon, 06 Nov 2006 13:55:00 -0000	[thread overview]
Message-ID: <454F3EB5.7010700@Yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

I have a server program where the main thread block on all signals and
handle them appropriately.  This was required for a graceful shutdown
(using SIGINT ) or a reconfigure ( HUP ). However, I see that, gdb
doesn't allow me to break into the debugger ( interrupt the running
program ) if I block SIGINT.  The "info signal" states that,
Signal        Stop      Print   Pass to program Description

SIGHUP        Yes       Yes     Yes             Hangup
SIGINT        Yes       Yes     No              Interrupt

Still, SIGINT is passed to the program being debugged instead of GDB
handling this.  I have attached a sample program where I can reproduce
this. I tried this on Solaris and HPUX.  Once I attach to the running
program, I can interrupt the program using "Ctrl-C".  But, this doesn't
work on gdb ( on SLES, SuSE 10.1 and RHAS 3.0 - gdb 6.4 and 6.0 ) and
the signal is delivered to the running program.  Any help is appreciated.

--jaimon

[-- Attachment #2: signal_test.cpp --]
[-- Type: text/plain, Size: 1163 bytes --]


#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>


int main(void)
{
	int err = 0;
	bool bShutdown = 0;
	sigset_t set, old;

	sigfillset(&set);
	sigdelset(&set,SIGTRAP);
//	sigdelset(&set, SIGINT );

	//
	//	Needed by gdb
	// 
	sigdelset(&set, SIGUSR1 );
	sigdelset(&set, SIGUSR2 );
	sigdelset(&set, SIGUNUSED );

   /* Java VM uses these signals in Linux */
   for(int s=SIGRTMIN; s <= SIGRTMAX - 4; s++)
		sigdelset(&set,s);

	if (pthread_sigmask(SIG_BLOCK, &set, 0) != 0)
		fprintf(stderr, "pthread_sigprocmask failed: %s\n", strerror(errno)); 

	//
	// Start additional threads
	//

	while (bShutdown == false)
	{ 
		int sig = 0; 
		siginfo_t info;

		if ((sig = sigwaitinfo(&set, &info)) == -1)
		{
			fprintf(stderr, "Received invalid signal -1.\n");
			continue;
		}

		switch (sig)
		{
			case SIGINT:
				fprintf(stderr, "Received SIGINT\n"); 
				// fall through
			case SIGTERM:
				fprintf(stderr, "Got SIGINT/SIGTERM signal, shutting down\n"); 
				bShutdown = true;
				break;
			default:
				fprintf(stderr, "Ignoring the unexpected signal, %d\n", sig);
				break;
		}
	}
	//
	// Do additional cleanup
	//
	return 0;
}

             reply	other threads:[~2006-11-06 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-06 13:55 Jaimon Jose [this message]
2006-11-06 14:05 ` Andreas Schwab
2006-11-06 14:16   ` Daniel Jacobowitz
2006-11-06 14:18   ` Jaimon Jose
2006-11-06 14:35     ` Daniel Jacobowitz

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=454F3EB5.7010700@Yahoo.com \
    --to=jjaimon@yahoo.com \
    --cc=gdb@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