Re: [gtk-list] Re: gdk_input_add



On May 09, Sascha Ziemann wrote:
> Des Herriott <des@ops.netcom.net.uk> writes:
> 
> |   setitimer(); /* raise a SIGALRM every 20ms */
> 
> Signals are a really complicated topic, specially when used with Gtk.
> Stevens wrote 60 pages about signals in simple programs, which do not
> use any other lib. Without exactly knowing the internals of Gtk, this
> will end in nasty buggy programs. I hoped that I can manage the
> problem completely with Gtk/Gdk features.

I agree that signals are fraught with danger.

However, I believe it is safe to use the above method, as long as you
use sigaction() to catch the SIGALRM, and as long as you ensure that
your signal handler is as simple as possible.  Having said that, I
don't know the Gtk internals well enough either - can someone else
comment on whether or not the above is a recipe for disaster?

The signal handler in XZX does nothing more than set a global variable
and return (which is checked periodically in the main loop to ensure
the time-slice has not been overrun).  XZX works reliably on every
version of Unix it's been built on (which is most of them), which
admittedly isn't proof that it's 100% safe, but it's strong evidence :-)

If you can do it without signals though, it's probably better.
Real-time graphical programming is fun :)

-- 
Des Herriott
des@ops.netcom.net.uk



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