Handling OS signals?



I have an application that forks off several child processes and then sleeps
most of the time, but it should show how many children exist at a given time.
I can receive SIGCHLD when a child exits, but I don't know of an elegant
way to tell GTK that I want my function called after the signal handler
returns.

GTK sleeps in GLib's poll() and any OS signal will invoke my signal handler
and then interrupt poll(). GLib will then look if there are events to be
dispatched and if none found, return to poll(). I could do processing in
OS signal handler, but that's not advisable, since most OS functions
are not guaranteed to be async safe. So I'd like to set a variable or two,
register one callback and return. Upon return, GLib should invoke that
callback to do the actual job. The problem is that I don't know which
(if any) function for callback registration is reentrant and safe to call
from an OS signal handler.

I could use timers or something, but that's ugly and inefficient.

-- 
 .-.   .-.    Life is a sexually transmitted disease.
(_  \ /  _)
     |        dave@srce.hr
     |        dave@fly.cc.fer.hr



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