News for hackers. Stuff that matters.
Re:Why Elixir (2014) by qohen on Friday August 18, 2017 @09:28AM (#15045878)
How do you handle operating system signals? like when your autoscale group decides to scala down and you get a SIGTERM with some time to handle it, what do you do?

This might help: from the release notes to Erlang R20 (i.e. latest):

A new event manager to handle a subset of OS signals in Erlang

It's documented in the docs for kernel here:

http://erlang.org/documentation/doc-9.0-rc2/lib/kernel-5.3/d...

You can write your own handler, which you'll install using gen_event (or :gen_event in Elixir), but even if you don't, there's a default handler which handles 3 signals, SIGUSER1, SIGQUIT and SIGTERM.

Per the link above, SIGTERM is handled like so:

The default handler will terminate Erlang normally. This is equivalent to calling init:stop().

Also worth a look, to see how os:set_signal/2 works (this allows you to decide which signals should be ignored, handled by the default handler or handled by your own handler):

http://erlang.org/documentation/doc-9.0-rc2/lib/kernel-5.3/d...

(And a shout out to legoscia on Stack Overflow for letting us know this might be available:

https://stackoverflow.com/a/41872533 )

Re:Why Elixir (2014) by anko on Friday August 18, 2017 @05:25PM (#15049839)
This is brilliant, I can't believe I missed it! Thank you
Re:Why Elixir (2014) by qohen on Friday August 18, 2017 @08:02PM (#15050696)
If you hadn't mentioned it, I wouldn't have gone researching it and then finding legocia's 2017 comment to a 2010 StackOverflow thread where he says that perhaps a pull request involving an "event manager for signals" might make it into R20.

So, you're welcome...and thank you for getting me to look :-)