Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0374-Add-support-for-SIGWINCH-system-signal.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0374-Add-support-for-SIGWINCH-system-signal.patch of Package erlang
From 0fcd57449597688c0eff2b07065be4e7612daca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <jean-sebastien.pedron@dumbbell.fr> Date: Tue, 1 Oct 2024 16:48:09 +0200 Subject: [PATCH 1/2] Add support for `SIGWINCH` system signal This signal is emitted when the terminal window is resized to allow an application to redraw its content. --- erts/emulator/beam/atom.names | 1 + erts/emulator/sys/unix/sys.c | 3 +++ erts/emulator/test/os_signal_SUITE.erl | 33 +++++++++++++++++++++++++- lib/kernel/doc/kernel_app.md | 2 ++ lib/kernel/src/os.erl | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/atom.names b/erts/emulator/beam/atom.names index 758c84d1c1..5686284187 100644 --- a/erts/emulator/beam/atom.names +++ b/erts/emulator/beam/atom.names @@ -674,6 +674,7 @@ atom sigint atom sigsegv atom sigtstp atom sigquit +atom sigwinch atom silent atom size atom skip diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c index 53cd17e44c..68479fa177 100644 --- a/erts/emulator/sys/unix/sys.c +++ b/erts/emulator/sys/unix/sys.c @@ -687,6 +687,7 @@ static RETSIGTYPE suspend_signal(int signum) SIGTSTP Stop Stop typed at terminal !SIGTTIN Stop Terminal input for background process !SIGTTOU Stop Terminal output for background process + SIGWINCH Ign Window size change */ @@ -707,6 +708,7 @@ signalterm_to_signum(Eterm signal) case am_sigchld: return SIGCHLD; case am_sigstop: return SIGSTOP; case am_sigtstp: return SIGTSTP; + case am_sigwinch: return SIGWINCH; default: return 0; } } @@ -728,6 +730,7 @@ signum_to_signalterm(int signum) case SIGCHLD: return am_sigchld; case SIGSTOP: return am_sigstop; case SIGTSTP: return am_sigtstp; /* ^z */ + case SIGWINCH: return am_sigwinch; default: return am_error; } } diff --git a/erts/emulator/test/os_signal_SUITE.erl b/erts/emulator/test/os_signal_SUITE.erl index 21e3bebb6b..affcd95ef4 100644 --- a/erts/emulator/test/os_signal_SUITE.erl +++ b/erts/emulator/test/os_signal_SUITE.erl @@ -41,7 +41,8 @@ t_sigterm/1, t_sigalrm/1, t_sigchld/1, - t_sigchld_fork/1]). + t_sigchld_fork/1, + t_sigwinch/1]). -define(signal_server, erl_signal_server). @@ -59,6 +60,7 @@ all() -> t_sigalrm, t_sigchld, t_sigchld_fork, + t_sigwinch, set_unset] end. @@ -298,6 +300,35 @@ sigchld_fork() -> os:set_signal(sigchld, ignore), ok. +t_sigwinch(_Config) -> + Pid1 = setup_service(), + OsPid = os:getpid(), + os:set_signal(sigwinch, handle), + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + Msgs1 = fetch_msgs(Pid1), + io:format("Msgs1: ~p~n", [Msgs1]), + [{notify,sigwinch}, + {notify,sigwinch}, + {notify,sigwinch}] = Msgs1, + %% no proc + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + %% ignore + Pid2 = setup_service(), + os:set_signal(sigwinch, ignore), + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + ok = kill("WINCH", OsPid), + Msgs2 = fetch_msgs(Pid2), + io:format("Msgs2: ~p~n", [Msgs2]), + [] = Msgs2, + %% reset to ignore (it's the default) + os:set_signal(sigwinch, ignore), + ok. + %% nif stubs diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index 4f634399fc..b19a35d126 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -108,6 +108,8 @@ <item><p>Stop process</p></item> <tag><c>sigtstp</c></tag> <item><p>Stop typed at terminal</p></item> + <tag><c>sigwinch</c></tag> + <item><p>Window size change</p></item> </taglist> <p>Setting OS signals are described in <seemfa marker="os#set_signal/2"><c>os:set_signal/2</c></seemfa>.</p> diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index adb31bd678..e730c085ad 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -302,7 +302,7 @@ Each signal my be set to one of the following options: -spec set_signal(Signal, Option) -> 'ok' when Signal :: 'sighup' | 'sigquit' | 'sigabrt' | 'sigalrm' | 'sigterm' | 'sigusr1' | 'sigusr2' | 'sigchld' | - 'sigstop' | 'sigtstp', + 'sigstop' | 'sigtstp' | 'sigwinch', Option :: 'default' | 'handle' | 'ignore'. set_signal(_Signal, _Option) -> -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor