Forwards SIGWINCH to the terminal driver.
A :gen_event handler for :erl_signal_server, which is where OTP delivers a
signal once :os.set_signal/2 has marked it as handled. SIGWINCH is relayed
to the driver given to init/1 as {:signal, :winch}. Every other signal is
ignored.
Install it with the driver as both the handler argument and the supervising process:
:os.set_signal(:sigwinch, :handle)
:gen_event.add_sup_handler(
:erl_signal_server,
{Drafter.Terminal.SignalWatcher, self()},
self()
)
Summary
Functions
Reply :ok to every call, leaving the state unchanged.
Relay :sigwinch to the driver as {:signal, :winch} and ignore every other signal.
Ignore every message.
Keep driver as the handler state. driver is where signals are relayed.
Remove the handler without touching the driver.
Types
Functions
Reply :ok to every call, leaving the state unchanged.
Relay :sigwinch to the driver as {:signal, :winch} and ignore every other signal.
iex> {:ok, driver} = Drafter.Terminal.SignalWatcher.init(self())
iex> Drafter.Terminal.SignalWatcher.handle_event(:sigwinch, driver)
iex> Drafter.Terminal.SignalWatcher.handle_event(:sigterm, driver)
iex> receive do
...> message -> message
...> after
...> 0 -> :nothing
...> end
{:signal, :winch}
Ignore every message.
Keep driver as the handler state. driver is where signals are relayed.
iex> Drafter.Terminal.SignalWatcher.init(self())
{:ok, self()}
Remove the handler without touching the driver.