Signal handler in XS module

172 views Asked by At

I have very simple constructor and destructor for some C-based library. Well, i need to catch signals like TERM and others to enforce destructor calling on perl's mandatory death with killall perl e.g. In fact i need local $SIG{TERM} for each object to be installed, written inside XS constructor. Is it possible? !thanx!

1

There are 1 answers

2
mob On

Not exactly. A signal is sent to and trapped by a process, not objects.

Another approach might be to maintain a global list of all the objects that must be cleaned up, and install a single signal handler that will clean up each object on that list.