X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Sun, 11 Jan 2009 19:41:25 -0500
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Signal handling in Win32 GUI programs
Message-ID: <20090112004125.GE21040@ednor.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <496A5C5D.9030703@gmail.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@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
Note-from-DJ: This may be spam

On Sun, Jan 11, 2009 at 08:53:49PM +0000, Andy Koppe wrote:
>>>I've added a thread doing 'for (;;) pause();', but unfortunately that
>>>doesn't seem to do the trick.  Do I need to go into Cygwin internals
>>>and wait directly on the Win32 event(s) used for signals?
>>sigwait() will probably work better than pause.
>
>That indeed works, thank you very much! I didn't know that function,
>very handy.  With that and threads, signal handlers with all their
>vagaries aren't really needed anymore, are they?

I have it on my todo list to see why pause doesn't work.  I'd like to do
some signal revamping someday but I don't want to destabilize 1.7.0 to
do that.

>And speaking of threads, does it make a difference whether one uses
>Pthreads or Win32 threads?  I mean apart from portability and the small
>overhead Pthreads presumably incur.

You really have to use pthreads.  Using non-posix methods is always asking
for trouble in Cygwin.

>MinTTY's got three such little helper threads hanging about now, doing
>waitpid() on the child process, read() on the child pty, and the
>abovementioned sigwait().  Would there be any point in trying to
>consolidate them into a single sigwait() process, using SIGCHLD and
>asynchronous reads?

Hmm.  I guess you could just do a sigwait on SIGCHLD and consolidate the
signal handling with that.  I don't think it makes sense to set up async
I/O just to do reads on the pty.  That would eliminate one thread at
least.

cgf

--
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/

