From d8d44d6138f3cebf551e2c19710846905ce00cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 1 May 2015 08:33:52 +0200 Subject: [PATCH] core: add signals "signal_sigterm" and "signal_sigquit" (closes #114) --- ChangeLog.asciidoc | 1 + doc/en/weechat_plugin_api.en.asciidoc | 10 ++++++++++ doc/fr/weechat_plugin_api.fr.asciidoc | 10 ++++++++++ doc/it/weechat_plugin_api.it.asciidoc | 12 ++++++++++++ doc/ja/weechat_plugin_api.ja.asciidoc | 12 ++++++++++++ src/core/weechat.c | 26 ++++++++++++++++++++------ 6 files changed, 65 insertions(+), 6 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index e87b1e061..924879b4a 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -19,6 +19,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] === New features +* core: add signals "signal_sigterm" and "signal_sigquit" (closes #114) * core: use environment variable WEECHAT_HOME on startup (closes #391) * core: remove WeeChat version from config files (closes #407) * core: add options weechat.look.quote_{nick_prefix|nick_suffix|time_format} to diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc index ceef1bb94..a66528c0d 100644 --- a/doc/en/weechat_plugin_api.en.asciidoc +++ b/doc/en/weechat_plugin_api.en.asciidoc @@ -8388,6 +8388,16 @@ List of signals sent by WeeChat and plugins: String: arguments for /quit | Command `/quit` issued by user +| weechat | signal_sigquit + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGQUIT received (quit request with core dump) + +| weechat | signal_sigterm + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGTERM received (graceful termination of WeeChat process) + | weechat | signal_sigwinch + _(WeeChat ≥ 0.4.3)_ | - | diff --git a/doc/fr/weechat_plugin_api.fr.asciidoc b/doc/fr/weechat_plugin_api.fr.asciidoc index f2877584d..3657cf5a0 100644 --- a/doc/fr/weechat_plugin_api.fr.asciidoc +++ b/doc/fr/weechat_plugin_api.fr.asciidoc @@ -8535,6 +8535,16 @@ Liste des signaux envoyés par WeeChat et les extensions : Chaîne : paramètres pour le /quit | La commande `/quit` a été exécutée par l'utilisateur +| weechat | signal_sigquit + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGQUIT reçu (requête pour quitter avec une copie de la mémoire) + +| weechat | signal_sigterm + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGTERM reçu (arrêt propre du processus WeeChat) + | weechat | signal_sigwinch + _(WeeChat ≥ 0.4.3)_ | - | diff --git a/doc/it/weechat_plugin_api.it.asciidoc b/doc/it/weechat_plugin_api.it.asciidoc index 827e485e4..ae8788ac3 100644 --- a/doc/it/weechat_plugin_api.it.asciidoc +++ b/doc/it/weechat_plugin_api.it.asciidoc @@ -8625,6 +8625,18 @@ List of signals sent by WeeChat and plugins: String: argomenti per /quit | Comando `/quit` digitato dall'utente +// TRANSLATION MISSING +| weechat | signal_sigquit + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGQUIT received (quit request with core dump) + +// TRANSLATION MISSING +| weechat | signal_sigterm + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGTERM received (graceful termination of WeeChat process) + // TRANSLATION MISSING | weechat | signal_sigwinch + _(WeeChat ≥ 0.4.3)_ | diff --git a/doc/ja/weechat_plugin_api.ja.asciidoc b/doc/ja/weechat_plugin_api.ja.asciidoc index c6982ba29..faa47b1b2 100644 --- a/doc/ja/weechat_plugin_api.ja.asciidoc +++ b/doc/ja/weechat_plugin_api.ja.asciidoc @@ -8387,6 +8387,18 @@ WeeChat とプラグインが送信するシグナルのリスト: String: /quit の引数 | ユーザがコマンド `/quit` を実行 +// TRANSLATION MISSING +| weechat | signal_sigquit + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGQUIT received (quit request with core dump) + +// TRANSLATION MISSING +| weechat | signal_sigterm + + _(WeeChat ≥ 1.2)_ | + - | + Signal SIGTERM received (graceful termination of WeeChat process) + | weechat | signal_sigwinch + _(WeeChat バージョン 0.4.3 以上で利用可)_ | - | diff --git a/src/core/weechat.c b/src/core/weechat.c index 464a769a8..23619fa3e 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -521,9 +521,16 @@ weechat_sighup () void weechat_sigquit () { - log_printf (_("Signal %s received, exiting WeeChat..."), "SIGQUIT"); - (void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL); - weechat_quit = 1; + int rc; + + rc = hook_signal_send ("signal_sigquit", + WEECHAT_HOOK_SIGNAL_STRING, NULL); + if (rc != WEECHAT_RC_OK_EAT) + { + log_printf (_("Signal %s received, exiting WeeChat..."), "SIGQUIT"); + (void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL); + weechat_quit = 1; + } } /* @@ -533,9 +540,16 @@ weechat_sigquit () void weechat_sigterm () { - log_printf (_("Signal %s received, exiting WeeChat..."), "SIGTERM"); - (void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL); - weechat_quit = 1; + int rc; + + rc = hook_signal_send ("signal_sigterm", + WEECHAT_HOOK_SIGNAL_STRING, NULL); + if (rc != WEECHAT_RC_OK_EAT) + { + log_printf (_("Signal %s received, exiting WeeChat..."), "SIGTERM"); + (void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL); + weechat_quit = 1; + } } /*