-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prim_tty: Use os:signal/2 to handle SIGCONT and SIGWINCH
[Why] Support for SIGCONT and SIGWINCH was added in previous commit to allow any Erlang application to react to them. Unfortunately, setting handlers for these two signals broke `prim_tty` which installed its own handlers in `prim_tty_nif.c`. [How] This patch changes `prim_tty` to use `os:signal/2` along with its own gen_event callbacu module to handle the two signals from the Erlang code, like any other Erlang application. The C code was removed because it is now unused.
- Loading branch information
Showing
6 changed files
with
81 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ | |
user_drv, | ||
user_sup, | ||
prim_tty, | ||
prim_tty_sighandler, | ||
disk_log, | ||
disk_log_1, | ||
disk_log_server, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
%% %CopyrightBegin% | ||
%% | ||
%% Copyright Ericsson AB 2024. All Rights Reserved. | ||
%% | ||
%% Licensed under the Apache License, Version 2.0 (the "License"); | ||
%% you may not use this file except in compliance with the License. | ||
%% You may obtain a copy of the License at | ||
%% | ||
%% http://www.apache.org/licenses/LICENSE-2.0 | ||
%% | ||
%% Unless required by applicable law or agreed to in writing, software | ||
%% distributed under the License is distributed on an "AS IS" BASIS, | ||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%% | ||
%% %CopyrightEnd% | ||
%% | ||
-module(prim_tty_sighandler). | ||
-moduledoc false. | ||
|
||
-behaviour(gen_event). | ||
|
||
-export([init/1, handle_event/2, handle_call/2, code_change/3]). | ||
|
||
init(#{parent := _, reader := _} = State) -> | ||
{ok, State}. | ||
|
||
handle_event(Signal, #{parent := Parent, reader := ReaderRef} = State) | ||
when Signal =:= sigcont orelse Signal =:= sigwinch -> | ||
ShortSignal = case Signal of | ||
sigcont -> cont; | ||
sigwinch -> winch | ||
end, | ||
Parent ! {ReaderRef, {signal, ShortSignal}}, | ||
{ok, State}; | ||
handle_event(_Signal, State) -> | ||
%% Other signals are ignored by `prim_tty'. | ||
{ok, State}. | ||
|
||
handle_call(_Request, State) -> | ||
{ok, ok, State}. | ||
|
||
code_change(_OldVsn, State, _Extra) -> | ||
{ok, State}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
%% -*- erlang -*- | ||
{incl_mods,[prim_tty, user_drv, group, shell, edlin, edlin_expand, io_lib]}. | ||
{incl_mods,[prim_tty, prim_tty_sighandler, user_drv, group, shell, edlin, edlin_expand, io_lib]}. | ||
|