From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 505 invoked by alias); 6 Nov 2006 13:55:23 -0000 Received: (qmail 492 invoked by uid 22791); 6 Nov 2006 13:55:22 -0000 X-Spam-Check-By: sourceware.org Received: from smtp109.plus.mail.mud.yahoo.com (HELO smtp109.plus.mail.mud.yahoo.com) (68.142.206.242) by sourceware.org (qpsmtpd/0.31) with SMTP; Mon, 06 Nov 2006 13:55:13 +0000 Received: (qmail 59382 invoked from network); 6 Nov 2006 13:55:11 -0000 Received: from unknown (HELO ?192.168.1.142?) (jjaimon@125.16.129.17 with plain) by smtp109.plus.mail.mud.yahoo.com with SMTP; 6 Nov 2006 13:55:10 -0000 X-YMail-OSG: YPgR.A4VM1m9CuY9ckeVhEaNHa77Bc1ohhWCileX15aPaIJMi9HZjYSJvmcYYrDPkdTua0wrJr6MO7FmaMjTOZNny.TwovstZ8pEfxKvRlTB4LV269UV5A-- Message-ID: <454F3EB5.7010700@Yahoo.com> Date: Mon, 06 Nov 2006 13:55:00 -0000 From: Jaimon Jose Reply-To: jjaimon@yahoo.com User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: gdb@sourceware.org Subject: pthread_sigmask and gdb Content-Type: multipart/mixed; boundary="------------030002030709090404090705" X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00021.txt.bz2 This is a multi-part message in MIME format. --------------030002030709090404090705 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 948 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 --------------030002030709090404090705 Content-Type: text/plain; name="signal_test.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="signal_test.cpp" Content-length: 1163 #include #include #include #include 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; } --------------030002030709090404090705--