Return-Path: william@bourbon.usc.edu Delivery-Date: Thu Oct 30 08:39:41 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m9UFdfol004006 for ; Thu, 30 Oct 2008 08:39:41 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m9UFpGpX008420 for ; Thu, 30 Oct 2008 08:51:16 -0700 Message-Id: <200810301551.m9UFpGpX008420@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CPU Hog Date: Thu, 30 Oct 2008 08:51:16 -0700 From: Bill Cheng Hi, I'm forwarding an e-mail from a student. I'm not sure if this is related to the same problem another student was talking about. But here it is. -- Bill Cheng // bill.cheng@usc.edu -----Original Message----- Date: Thu, 30 Oct 2008 00:24:27 -0700 From: "Brian A. Trimmer" To: Bill Cheng Subject: Re: CPU Hog Not sure if this is the same case, but I had a similar situation and solved it by reblocking SIGINT once I had caught it: while (true) { /** define sigs to catch **/ sigaddset(&sigs, SIGINT); pthread_sigmask(SIG_UNBLOCK, &sigs, NULL); sigwait(&sigs,&caught); //caught a sig pthread_sigmask(SIG_BLOCK, &sigs, NULL); //block any further sigs /** do stuff **/ } This way the SIGINT is blocked until the next time around the while loop, where it is unblocked and caught On Wed, Oct 29, 2008 at 7:42 PM, Bill Cheng wrote: > Someone wrote: > > > I am using pthread_sigmask to unblock the SIGINT signal in my command line > > handler thread. I am catching and handling the signal in the same thread. > > But my thread is not able to catch more than one SIGINT. I called sighandler > > within sighandler but nothing seems to be working. My program terminates on > > the second Ctrl+C. > > I just tried the code in "man pthread_sigmask" again (with a > little modification so that it loops forever) and it seems to > work just fine. I can send after and it > kept going. > > In that code, it uses sigaction() to specify a signal handler. > Are you doing that? Or are you using signal()? > -- > Bill Cheng // bill.cheng@usc.edu