Re: SIGINT signal handler for perl-Glib



On Thursday, February 19, 2004, at 04:22 PM, Sameer VK wrote:

I'm trying to interface a Glib2-based C/C++ library (call it <app>) to Perl. Does it make sense to use perl-Glib for the Glib part and SWIG (for the <app>part)?

i'm my experience, swig isn't all that useful, as your library's interface usually requires a fair amount of tweaking.

if, as you say, your library is Glib2-based then you are in luck, because we provide all sorts of helpful tools to make it easy to build bindings that not only work well with Perl but with gtk2-perl. in fact, that's a design goal for the project. ;-)


This would let me write Perl code like:

use Glib;
use <app-lib>;

__app_init();

bah! unless there's an important need to postpone the initialization (as with Gtk2->init), you'd put the app_init() call in your module's BOOT: section so that it happens on load (as with g_type_init() in the Glib bindings).

our binding utilities will take care of reference counting on your GObjects and all that stuff. You Want To Use Our Stuff. :-)

come talk to us in #gtk-perl on irc.gnome.org, or email me off-list if you can't publicize the info about your library.


The issue I've run into is how to shutdown gracefully and clean up the app when the user sends a SIGINT or SIGHUP. The app code does it by setting up a signal handler for those 2 signals which overrides the ones in libglib2 (it also does a mainloop->quit).

erm... my grep skills lead me to no code in glib that installs handlers for either SIGINT or SIGHUP. and really, i wouldn't expect them to. the perl bindings do not mess with async signals at all.


When I tried setting a signal handler in Perl:
$SIG{INT} = \&app_cleanup, the script did not respond, probably because the handler in the perl-Glib library cannot be overridden?

well, there's no handler, so it's not that. if you stopped the mainloop in your handler, that would explain why the gui stopped responding. beyond that, i need more info. again, if you can't divulge details publicly, just email me offlist, i'd be happy to help.


--
Holy crap, dude, we have kids!
        -- Elysse, six days after giving birth to twins




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