Re: SIGINT with gtk_main
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtk-app-devel-list gnome org
- Subject: Re: SIGINT with gtk_main
- Date: Thu, 22 Mar 2007 23:18:09 +0000
On Wednesday 21 March 2007 17:50, Michiel Jan Laurens de Hoon wrote:
For my application, I need to run gtk_main but I want to quit gtk_main
when either input is available on stdin or the user presses Ctrl-C. The
former is easy (using g_io_add_watch), but I am not sure what the best
approach is to handle Ctrl-C. Right now I am using g_timeout_add to
check every 100 milliseconds if Ctrl-C has been hit. But I'm wondering
if there is a better way to do this, preferably without checking
periodically for a Ctrl-C.
The relevant code looks as follows:
[snip]
You can write to a pipe in the signal handler (assuming you are using Unix as
your question implies), as write() is async-signal-safe - but set the pipe
non-blocking as in the unlikely event of it filling up and blocking on write
you will deadlock the program. You can watch on the pipe in the main loop
using GIOChannel.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]