Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1565-Add-support-for-SIGINFO-system-signal.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1565-Add-support-for-SIGINFO-system-signal.patch of Package erlang
From 2dc1189382c940d97e3fce14e1b4773eff8b5cf1 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:49:15 +0200 Subject: [PATCH 2/2] Add support for `SIGINFO` system signal This signal is emitted when a user type Ctrl+T in a terminal. This is only supported by few operating systems such as *BSD and OSX. By default, the operating system displays on stdout the system process PID, the system load and the duration the process is running. The signal allows the application to display more details about its status and progress. --- erts/emulator/beam/atom.names | 1 + erts/emulator/sys/unix/sys.c | 7 ++++ erts/emulator/test/os_signal_SUITE.erl | 45 +++++++++++++++++++++++++- lib/kernel/doc/kernel_app.md | 4 +++ lib/kernel/src/os.erl | 2 +- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/atom.names b/erts/emulator/beam/atom.names index 5686284187..ff5f2c1303 100644 --- a/erts/emulator/beam/atom.names +++ b/erts/emulator/beam/atom.names @@ -675,6 +675,7 @@ atom sigsegv atom sigtstp atom sigquit atom sigwinch +atom siginfo atom silent atom size atom spawn_executable diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c index 68479fa177..da034cb373 100644 --- a/erts/emulator/sys/unix/sys.c +++ b/erts/emulator/sys/unix/sys.c @@ -688,6 +688,7 @@ static RETSIGTYPE suspend_signal(int signum) !SIGTTIN Stop Terminal input for background process !SIGTTOU Stop Terminal output for background process SIGWINCH Ign Window size change + SIGINFO Ign Status request from keyboard */ @@ -709,6 +710,9 @@ signalterm_to_signum(Eterm signal) case am_sigstop: return SIGSTOP; case am_sigtstp: return SIGTSTP; case am_sigwinch: return SIGWINCH; +#ifdef SIGINFO + case am_siginfo: return SIGINFO; +#endif /* defined(SIGINFO) */ default: return 0; } } @@ -731,6 +735,9 @@ signum_to_signalterm(int signum) case SIGSTOP: return am_sigstop; case SIGTSTP: return am_sigtstp; /* ^z */ case SIGWINCH: return am_sigwinch; +#ifdef SIGINFO + case SIGINFO: return am_siginfo; /* ^t */ +#endif /* defined(SIGINFO) */ default: return am_error; } } diff --git a/erts/emulator/test/os_signal_SUITE.erl b/erts/emulator/test/os_signal_SUITE.erl index affcd95ef4..4887baf732 100644 --- a/erts/emulator/test/os_signal_SUITE.erl +++ b/erts/emulator/test/os_signal_SUITE.erl @@ -42,7 +42,8 @@ t_sigalrm/1, t_sigchld/1, t_sigchld_fork/1, - t_sigwinch/1]). + t_sigwinch/1, + t_siginfo/1]). -define(signal_server, erl_signal_server). @@ -61,6 +62,7 @@ all() -> t_sigchld, t_sigchld_fork, t_sigwinch, + t_siginfo, set_unset] end. @@ -329,6 +331,47 @@ t_sigwinch(_Config) -> os:set_signal(sigwinch, ignore), ok. +t_siginfo(_Config) -> + SiginfoSupported = try + os:set_signal(siginfo, default), + true + catch + error:badarg -> + false + end, + case SiginfoSupported of + true -> + Pid1 = setup_service(), + OsPid = os:getpid(), + os:set_signal(siginfo, handle), + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + Msgs1 = fetch_msgs(Pid1), + io:format("Msgs1: ~p~n", [Msgs1]), + [{notify,siginfo}, + {notify,siginfo}, + {notify,siginfo}] = Msgs1, + %% no proc + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + %% ignore + Pid2 = setup_service(), + os:set_signal(siginfo, ignore), + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + ok = kill("INFO", OsPid), + Msgs2 = fetch_msgs(Pid2), + io:format("Msgs2: ~p~n", [Msgs2]), + [] = Msgs2, + %% reset to ignore (it's the default) + os:set_signal(siginfo, ignore); + false -> + ok + end, + ok. + %% nif stubs diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index b19a35d126..186ce889e5 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -110,6 +110,11 @@ <item><p>Stop typed at terminal</p></item> <tag><c>sigwinch</c></tag> <item><p>Window size change</p></item> + <tag><c>siginfo</c></tag> + <item><p>Status request from keyboard. + Note several operating systems (Linux in particular) do not support this signal. + <c>os:set_signal/2</c> will thow a <c>badarg</c> exception if support is missing. + </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 e730c085ad..bab043370d 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' | 'sigwinch', + 'sigstop' | 'sigtstp' | 'sigwinch' | 'siginfo', 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