X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 	tests=AWL,BAYES_00,J_CHICKENPOX_43,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <496C42C7.8040104@gmail.com>
Date: Tue, 13 Jan 2009 07:29:12 +0000
From: Andy Koppe <andy.koppe@gmail.com>
User-Agent: Thunderbird 2.0.0.18 (Windows/20081105)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: Signal handling in Win32 GUI programs
References: <496A1DBC.7070004@gmail.com> <20090111163729.GB9992@ednor.casa.cgf.cx> <496A24DE.1080101@gmail.com> <20090111180740.GC10049@ednor.casa.cgf.cx> <496A5C5D.9030703@gmail.com> <20090112004125.GE21040@ednor.casa.cgf.cx>
In-Reply-To: <20090112004125.GE21040@ednor.casa.cgf.cx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Actually I still can't quite get signal handling in MinTTY to work 
right. SIGINT is fine, but SIGTERM, SIGHUP, and SIGKILL don't seem to 
get to sigwait(), instead still invoking the default handler, i.e. 
terminating MinTTY without SIGHUP being sent to the command inside it.

Here's what I got:

   static const sigset_t term_sigs =
     1<<SIGHUP | 1<<SIGKILL | 1<<SIGTERM | 1<<SIGINT;

   static void *
   signal_thread(void *arg)
   {
     int sig;
     sigwait(&term_sigs, &sig);
     puts("signalled");
     if (pid)
       kill(pid, SIGHUP);
     exit(0);
   }

And in the main thread:

     pthread_sigmask(SIG_BLOCK, &term_sigs, 0);
     pthread_t thread;
     pthread_create(&thread, 0, signal_thread, 0);

Anything obvious missing?

Andy

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

