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

Lev Walkin vlm@REDACTED
Fri Jun 20 03:55:18 CEST 2008


Colm Dougan wrote:
> On Thu, Jun 19, 2008 at 5:59 PM, Maxim Treskin <zerthurd@REDACTED> wrote:
>> Hello
>>
>> Handling of UNIX-signal is not portable feature through many OS. So,
>> you must write OS-specified driver for this operations.
> 
> Thanks - that is the answer I expected.  So what do people generally
> do in situations that  normally call for signal handling?  For example
> if I shutdown a machine and all my processes get sent a TERM signal
> but I don't want my erlang process to get killed mercilessly.  What do
> people normally do?  An OS specific driver seems like a relatively
> difficult option.  Do people normally wrap the erlang process in
> another program/script that knows how to intercept signals and which
> then sends RPC to the erlang process?  I'm just seeking guidance on
> the standard  practice (I already looked at what yaws and ejabberd do
> on Linux).


You could create a server listening to TCP or UDP port and have a
matching script (e.g. `echo "msg" | telnet localhost 1234`) that
you can invoke during shutdown to tell Erlang to terminate.

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.

-- 
Lev Walkin
vlm@REDACTED



More information about the erlang-questions mailing list