diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-28 17:39:33 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-28 17:39:33 +0200 |
commit | cc2b44a8ec1930cb385a1d38939c7a48a37029db (patch) | |
tree | ab1b000bd80d2e13dd4c1fbd2cd448b08a7b58d5 /src/core | |
parent | 5ecb1adc344a106b9f1167930798bbcb3e286b14 (diff) | |
download | weechat-cc2b44a8ec1930cb385a1d38939c7a48a37029db.zip |
core: add key ctrl+z to suspend WeeChat process (closes #985)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 23 | ||||
-rw-r--r-- | src/core/wee-signal.c | 12 | ||||
-rw-r--r-- | src/core/wee-signal.h | 1 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 58e767b2b..10a3a823a 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -59,12 +59,13 @@ #include "wee-secure.h" #include "wee-secure-buffer.h" #include "wee-secure-config.h" +#include "wee-signal.h" #include "wee-string.h" +#include "wee-sys.h" #include "wee-upgrade.h" #include "wee-utf8.h" #include "wee-util.h" #include "wee-version.h" -#include "wee-sys.h" #include "../gui/gui-bar.h" #include "../gui/gui-bar-item.h" #include "../gui/gui-bar-item-custom.h" @@ -7801,6 +7802,12 @@ COMMAND_CALLBACK(sys) return WEECHAT_RC_OK; } + if (string_strcmp (argv[1], "suspend") == 0) + { + signal_suspend (); + return WEECHAT_RC_OK; + } + COMMAND_ERROR; } @@ -9489,12 +9496,16 @@ command_init () hook_command ( NULL, "sys", N_("system actions"), - N_("get rlimit|rusage"), - N_(" get: display system info\n" - "rlimit: display resource limits " + N_("get rlimit|rusage" + " || suspend"), + N_(" get: display system info\n" + " rlimit: display resource limits " "(see /help weechat.startup.sys_rlimit and man getrlimit)\n" - "rusage: display resource usage (see man getrusage)"), - "get rlimit|rusage", + " rusage: display resource usage (see man getrusage)\n" + "suspend: suspend WeeChat and go back to the shell, by sending " + "signal SIGTSTP to the WeeChat process"), + "get rlimit|rusage" + " || suspend", &command_sys, NULL, NULL); } diff --git a/src/core/wee-signal.c b/src/core/wee-signal.c index 54c7019e5..d29cf6468 100644 --- a/src/core/wee-signal.c +++ b/src/core/wee-signal.c @@ -37,6 +37,7 @@ #include "wee-log.h" #include "wee-string.h" #include "../gui/gui-buffer.h" +#include "../gui/gui-window.h" #include "../plugins/plugin.h" @@ -294,6 +295,17 @@ signal_handle () } /* + * Suspends WeeChat process. + */ + +void +signal_suspend () +{ + kill (getpid (), SIGTSTP); + gui_window_ask_refresh (2); +} + +/* * Initializes signal. */ diff --git a/src/core/wee-signal.h b/src/core/wee-signal.h index 8d8c43fb4..90f7e7c12 100644 --- a/src/core/wee-signal.h +++ b/src/core/wee-signal.h @@ -32,6 +32,7 @@ extern int signal_search_number (int signal_number); extern int signal_search_name (const char *name); extern void signal_catch (int signum, void (*handler)(int)); extern void signal_handle (); +extern void signal_suspend (); extern void signal_init (); #endif /* WEECHAT_SIGNAL_H */ |