Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Handle UNIX signals in Erlang
Erlang C
branch: master

Added to gitignore.

latest commit 5d69a20d79
Jamie Kingsbery authored

README.md

sighandler

License: Apache 2

1> application:start(sighandler).
ok
2> {ok, Ref} = sighandler:install(hup, fun() -> io:format("HUP!~n") end).
{ok,#Ref<0.0.0.66>}
3> os:cmd(io_lib:format("kill -HUP ~s", [os:getpid()])).
HUP!
[]
4> ok = sighandler:remove(Ref).
ok
3> os:cmd(io_lib:format("kill -HUP ~s", [os:getpid()])).
Hangup: 1

Should work with Erlang R13B04 or later on UNIX like platforms. Has been known to work with R13B04 and R15B on Darwin and with R14B04 on Linux.

To add a signal handler using configuration instead of programmatically, first create a config file

#hello.config
[
    {sighandler, [
        {handlers, [
            {hup, {io, fwrite, ["Hello, world!~n"]}}
        ]}
    ]}
].

Then start erlang:

erl -pa ebin/ -config $CONFIGDIR/hello -s sighandler

Then the handler will automatically be registered.

Something went wrong with that request. Please try again.