RE: SIGINT with gtk_main



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

Chris wrote:
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.

Thanks! That works fine (I tried this on Linux and Mac OS X).

Does it matter if I'd be using Windows instead? It's a bit hard to try
because of some DLL incompatibilities, but that can be resolved. Or is there
some fundamental reason why this wouldn't work on Windows? My previous
solution
checking for an interrupt periodically seems to work fine on Windows, though
it
is of course hard to tell with async signals.

Thanks again,

--Michiel.



Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]