[erlang-questions] Signal handling (TERM, INT etc)

Lev Walkin <>
Tue Jul 1 22:44:52 CEST 2008


Claes Wikström wrote:
> Lev Walkin wrote:
> 
>> Second, you can create a linked-in driver which sends a message
>> back to a corresponding server. This allows you to intercept signals
>> directly instead of relying on some external notificator.
>>
> 
> Mind you not in the signalhandler though - that will break major
> havoc with the runtime. There is no good way as far as I know to
> have a sighandler in Erlang.
> 
> Only possible solution I see is to
> 
> 1. Have a socket setup from the driver to the beam (over loopback)
> 2. in the sighandler write some data on the socket.

Just to clarify, my idea was:

1. create a linked-in driver which does the following
    a) establishes a signal handler
    b) creates a pipe(2)
    c) registers one end of the pipe with erlang runtime
       to get proper FD activity notifications

2. in the signal handler, write a byte into the other end
    of the pre-established pipe(2).

3. in the main body of the linked-in driver, send some message
    to erlang when Erlang VM notifies it about FD activity.

I haven't done it though, so there might be something wrong I
don't see yet.

-- 
Lev



More information about the erlang-questions mailing list