diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 349473a74..311ca83e7 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -20,6 +20,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: + * core: add options to customize commands executed on system signals received (SIGHUP, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2) (issue #1595) + * core: quit WeeChat by default when signal SIGHUP is received in normal run, reload configuration in weechat-headless (issue #1595) * api: add info "weechat_daemon" Bug fixes:: diff --git a/doc/de/includes/autogen_user_options.de.adoc b/doc/de/includes/autogen_user_options.de.adoc index cbf9ce760..6948cac47 100644 --- a/doc/de/includes/autogen_user_options.de.adoc +++ b/doc/de/includes/autogen_user_options.de.adoc @@ -1308,6 +1308,36 @@ ** Werte: on, off ** Standardwert: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** Beschreibung: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** Beschreibung: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** Beschreibung: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** Beschreibung: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** Beschreibung: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** Beschreibung: pass:none[Nach dem Start von WeeChat wird dieser Befehl aufgerufen. Dies geschieht nachdem die Erweiterungen geladen worden sind (mehrere Befehle sind durch ";" zu trennen) (Hinweis: Inhalt wird evaluiert, siehe /help eval)] ** Typ: Zeichenkette diff --git a/doc/de/weechat_user.de.adoc b/doc/de/weechat_user.de.adoc index e492aea6d..7cf4ac594 100644 --- a/doc/de/weechat_user.de.adoc +++ b/doc/de/weechat_user.de.adoc @@ -2453,6 +2453,8 @@ Sektion in Datei _weechat.conf_: | proxy | <> + /set weechat.proxy.* | Proxy Optionen. | network | /set weechat.network.* | Netzwerk/SSL Optionen. +// TRANSLATION MISSING +| signal | /set weechat.signal.* | Signal options. | bar | <> + /set weechat.bar.* | Optionen für die Bars. | layout | <> | Layouts. diff --git a/doc/en/includes/autogen_user_options.en.adoc b/doc/en/includes/autogen_user_options.en.adoc index 41ff189ec..41a23e50e 100644 --- a/doc/en/includes/autogen_user_options.en.adoc +++ b/doc/en/includes/autogen_user_options.en.adoc @@ -1308,6 +1308,36 @@ ** values: on, off ** default value: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** description: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** type: string +** values: any string +** default value: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** description: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** type: string +** values: any string +** default value: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** description: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** type: string +** values: any string +** default value: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** description: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** type: string +** values: any string +** default value: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** description: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** type: string +** values: any string +** default value: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** description: pass:none[command executed when WeeChat starts, after loading plugins (note: content is evaluated, see /help eval)] ** type: string diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index 7a30165a5..d7474a971 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -140,6 +140,7 @@ WeeChat "core" is located in following directories: |    wee-secure.c | Secured data functions. |    wee-secure-buffer.c | Secured data buffer. |    wee-secure-config.c | Secured data options (file sec.conf). +|    wee-signal.c | Signal functions. |    wee-string.c | Functions on strings. |    wee-upgrade-file.c | Internal upgrade system. |    wee-upgrade.c | Upgrade for WeeChat core (buffers, lines, history, ...). @@ -401,6 +402,7 @@ WeeChat "core" is located in following directories: |          test-core-infolist.cpp | Tests: infolists. |          test-core-list.cpp | Tests: lists. |          test-core-secure.cpp | Tests: secured data. +|          test-core-signal.cpp | Tests: signals. |          test-core-string.cpp | Tests: strings. |          test-core-url.cpp | Tests: URLs. |          test-core-utf8.cpp | Tests: UTF-8. diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc index 78788421c..b31fa0e42 100644 --- a/doc/en/weechat_user.en.adoc +++ b/doc/en/weechat_user.en.adoc @@ -2410,6 +2410,7 @@ Sections in file _weechat.conf_: | proxy | <> + /set weechat.proxy.* | Proxy options. | network | /set weechat.network.* | Network/SSL options. +| signal | /set weechat.signal.* | Signal options. | bar | <> + /set weechat.bar.* | Bar options. | layout | <> | Layouts. diff --git a/doc/fr/includes/autogen_user_options.fr.adoc b/doc/fr/includes/autogen_user_options.fr.adoc index d396932cf..3c80de870 100644 --- a/doc/fr/includes/autogen_user_options.fr.adoc +++ b/doc/fr/includes/autogen_user_options.fr.adoc @@ -1308,6 +1308,36 @@ ** valeurs: on, off ** valeur par défaut: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** description: pass:none[commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent être séparées par des point-virgules (note : le contenu est évalué, voir /help eval)] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** description: pass:none[commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent être séparées par des point-virgules (note : le contenu est évalué, voir /help eval)] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** description: pass:none[commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent être séparées par des point-virgules (note : le contenu est évalué, voir /help eval)] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** description: pass:none[commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent être séparées par des point-virgules (note : le contenu est évalué, voir /help eval)] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** description: pass:none[commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent être séparées par des point-virgules (note : le contenu est évalué, voir /help eval)] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** description: pass:none[commande exécutée quand WeeChat démarre, après le chargement des extensions (note : le contenu est évalué, voir /help eval)] ** type: chaîne diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index d4d8fa113..36d917d60 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -142,6 +142,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants : |    wee-secure.c | Fonctions pour les données sécurisées. |    wee-secure-buffer.c | Tampon pour les données sécurisées. |    wee-secure-config.c | Options des données sécurisées (fichier sec.conf). +|    wee-signal.c | Fonctions sur les signaux. |    wee-string.c | Fonctions sur les chaînes de caractères. |    wee-upgrade-file.c | Système de mise à jour interne. |    wee-upgrade.c | Mise à jour du cœur de WeeChat (tampons, lignes, historique, ...). @@ -403,6 +404,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants : |          test-core-infolist.cpp | Tests : infolists. |          test-core-list.cpp | Tests : listes. |          test-core-secure.cpp | Tests : données sécurisées. +|          test-core-signal.cpp | Tests : signaux. |          test-core-string.cpp | Tests : chaînes. |          test-core-url.cpp | Tests : URLs. |          test-core-utf8.cpp | Tests : UTF-8. diff --git a/doc/fr/weechat_user.fr.adoc b/doc/fr/weechat_user.fr.adoc index 8274f8241..fb058e4e7 100644 --- a/doc/fr/weechat_user.fr.adoc +++ b/doc/fr/weechat_user.fr.adoc @@ -2493,6 +2493,7 @@ Sections dans le fichier _weechat.conf_ : | proxy | <> + /set weechat.proxy.* | Options des proxies. | network | /set weechat.network.* | Options réseau/SSL. +| signal | /set weechat.signal.* | Options sur les signaux. | bar | <> + /set weechat.bar.* | Options des barres. | layout | <> | Dispositions. diff --git a/doc/it/includes/autogen_user_options.it.adoc b/doc/it/includes/autogen_user_options.it.adoc index 94c056eca..8fb4a6f6e 100644 --- a/doc/it/includes/autogen_user_options.it.adoc +++ b/doc/it/includes/autogen_user_options.it.adoc @@ -1308,6 +1308,36 @@ ** valori: on, off ** valore predefinito: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** descrizione: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** descrizione: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** descrizione: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** descrizione: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** descrizione: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** descrizione: pass:none[comando eseguito all'avvio di WeeChat, dopo il caricamento dei plugin (nota: il contenuto viene valutato, consultare /help eval)] ** tipo: stringa diff --git a/doc/it/weechat_user.it.adoc b/doc/it/weechat_user.it.adoc index 70d63701e..d806943cf 100644 --- a/doc/it/weechat_user.it.adoc +++ b/doc/it/weechat_user.it.adoc @@ -2585,6 +2585,8 @@ Sections in file _weechat.conf_: | proxy | <> + /set weechat.proxy.* | Proxy options. | network | /set weechat.network.* | Network/SSL options. +// TRANSLATION MISSING +| signal | /set weechat.signal.* | Signal options. | bar | <> + /set weechat.bar.* | Bar options. | layout | <> | Layouts. diff --git a/doc/ja/includes/autogen_user_options.ja.adoc b/doc/ja/includes/autogen_user_options.ja.adoc index 4925e6803..db2bcf75d 100644 --- a/doc/ja/includes/autogen_user_options.ja.adoc +++ b/doc/ja/includes/autogen_user_options.ja.adoc @@ -1308,6 +1308,36 @@ ** 値: on, off ** デフォルト値: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** 説明: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** 説明: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** 説明: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** 説明: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** 説明: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** 説明: pass:none[WeeChat が実行され、プラグインのロード後に実行されるコマンド (注意: 値は評価されます、/help eval を参照してください)] ** タイプ: 文字列 diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index b77e1c426..9d2b712c1 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -148,6 +148,8 @@ WeeChat "core" は以下のディレクトリに配置されています: |    wee-secure.c | データ保護用の関数 |    wee-secure-buffer.c | データ保護用のバッファ |    wee-secure-config.c | 安全なデータオプション (sec.conf ファイル) +// TRANSLATION MISSING +|    wee-signal.c | Signal functions. |    wee-string.c | 文字列関数 |    wee-upgrade-file.c | 内部アップグレードシステム |    wee-upgrade.c | WeeChat コアのアップグレード (バッファ、行、履歴、...) @@ -413,6 +415,8 @@ WeeChat "core" は以下のディレクトリに配置されています: |          test-core-infolist.cpp | テスト: インフォリスト |          test-core-list.cpp | テスト: リスト |          test-core-secure.cpp | テスト: データ保護 +// TRANSLATION MISSING +|          test-core-signal.cpp | テスト: signals. |          test-core-string.cpp | テスト: 文字列 |          test-core-url.cpp | テスト: URL |          test-core-utf8.cpp | テスト: UTF-8 diff --git a/doc/ja/weechat_user.ja.adoc b/doc/ja/weechat_user.ja.adoc index 05b1b1a03..8cf81803b 100644 --- a/doc/ja/weechat_user.ja.adoc +++ b/doc/ja/weechat_user.ja.adoc @@ -2471,6 +2471,8 @@ _weechat.conf_ ファイル内のセクション: | proxy | <> + /set weechat.proxy.* | プロキシオプション | network | /set weechat.network.* | ネットワーク/SSL オプション +// TRANSLATION MISSING +| signal | /set weechat.signal.* | Signal options. | bar | <> + /set weechat.bar.* | バーオプション | layout | <> | レイアウト diff --git a/doc/pl/includes/autogen_user_options.pl.adoc b/doc/pl/includes/autogen_user_options.pl.adoc index 401277e96..34c850338 100644 --- a/doc/pl/includes/autogen_user_options.pl.adoc +++ b/doc/pl/includes/autogen_user_options.pl.adoc @@ -1308,6 +1308,36 @@ ** wartości: on, off ** domyślna wartość: `+on+` +* [[option_weechat.signal.sighup]] *weechat.signal.sighup* +** opis: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+"${if:${info:weechat_headless}?/reload:/quit -yes}"+` + +* [[option_weechat.signal.sigquit]] *weechat.signal.sigquit* +** opis: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+"/quit -yes"+` + +* [[option_weechat.signal.sigterm]] *weechat.signal.sigterm* +** opis: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+"/quit -yes"+` + +* [[option_weechat.signal.sigusr1]] *weechat.signal.sigusr1* +** opis: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+""+` + +* [[option_weechat.signal.sigusr2]] *weechat.signal.sigusr2* +** opis: pass:none[command to execute when the signal is received, multiple commands can be separated by semicolons (note: content is evaluated, see /help eval)] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+""+` + * [[option_weechat.startup.command_after_plugins]] *weechat.startup.command_after_plugins* ** opis: pass:none[komenda wykonana kiedy WeeChat jest uruchamiany, po załadowaniu wtyczek (uwaga: zawartość jest przetwarzana, zobacz /help eval)] ** typ: ciąg diff --git a/doc/pl/weechat_user.pl.adoc b/doc/pl/weechat_user.pl.adoc index 353a7fc50..5ea08817b 100644 --- a/doc/pl/weechat_user.pl.adoc +++ b/doc/pl/weechat_user.pl.adoc @@ -2426,6 +2426,8 @@ Sekcje w pliku _weechat.conf_: | proxy | <> + /set weechat.proxy.* | Opcje proxy. | network | /set weechat.network.* | Opcje sieci/SSL. +// TRANSLATION MISSING +| signal | /set weechat.signal.* | Signal options. | bar | <> + /set weechat.bar.* | Opcje pasków. | layout | <> | Układy. diff --git a/po/POTFILES.in b/po/POTFILES.in index 155f68c9c..9be72f0fc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -77,6 +77,8 @@ ./src/core/wee-secure-buffer.h ./src/core/wee-secure-config.c ./src/core/wee-secure-config.h +./src/core/wee-signal.c +./src/core/wee-signal.h ./src/core/wee-string.c ./src/core/wee-string.h ./src/core/wee-upgrade.c diff --git a/po/cs.po b/po/cs.po index f53862161..6a895a327 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -4191,6 +4191,12 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "uložit soubory s nastavením při ukončení pluginů" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "příkaz spuštěný při startu WeeChat, po načtení pluginů" + msgid "FATAL: error initializing configuration options" msgstr "FATÁLNÍ: chyba při inicializaci konfiguračních nastavení" @@ -4612,14 +4618,6 @@ msgstr "Barvy WeeChat (použité: %d, zbývá: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminál ztracen, ukončuji WeeChat..." -#, fuzzy, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Obdržen signál %s, ukončuji WeeChat..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Obdržen signál %s, ukončuji WeeChat..." - msgid "Mouse is enabled" msgstr "Myš je zapnuta" @@ -13241,6 +13239,14 @@ msgstr "%s%s: vypršel časový limit \"%s\" pro %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: nemohu se připojit\" neočekávaná chyba (%d)" +#, fuzzy, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Obdržen signál %s, ukončuji WeeChat..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Obdržen signál %s, ukončuji WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Chráněná data \"%s\" smazána" diff --git a/po/de.po b/po/de.po index b9c61d33d..4c43615fb 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-03-14 13:36+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -5110,6 +5110,15 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "speichert Konfigurationen, falls Erweiterungen beendet werden" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"Nach dem Start von WeeChat wird dieser Befehl aufgerufen. Dies geschieht " +"nachdem die Erweiterungen geladen worden sind (mehrere Befehle sind durch \";" +"\" zu trennen) (Hinweis: Inhalt wird evaluiert, siehe /help eval)" + msgid "FATAL: error initializing configuration options" msgstr "FATAL: Fehler bei der Initialisierung der Konfigurationseinstellungen" @@ -5572,14 +5581,6 @@ msgstr "WeeChat Farben (in Benutzung: %d; noch frei verfügbar: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal verloren, beende WeeChat..." -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Signal %s empfangen, Konfiguration neu laden..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Signal %s empfangen, beende WeeChat..." - msgid "Mouse is enabled" msgstr "Maus ist aktiv" @@ -15555,6 +15556,14 @@ msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "" "%s%s: Verbindung konnte nicht hergestellt werden: unerwarteter Fehler (%d)" +#, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Signal %s empfangen, Konfiguration neu laden..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Signal %s empfangen, beende WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Schutzwürdige Information \"%s\" gelöscht" diff --git a/po/es.po b/po/es.po index 6e1ba6a16..0d96a1d55 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -4384,6 +4384,12 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "guardar archivos de configuración al descargar extensiones" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "comando ejecutado cuando WeeChat inicia, después de cargar los plugins" + msgid "FATAL: error initializing configuration options" msgstr "FATAL: error al inicializar las opciones de configuración" @@ -4802,14 +4808,6 @@ msgstr "Colores de WeeChat (en uso: %d, disponibles: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Se perdió la terminal, cerrando WeeChat..." -#, fuzzy, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Señal %s recibida, cerrando WeeChat..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Señal %s recibida, cerrando WeeChat..." - msgid "Mouse is enabled" msgstr "Ratón activado" @@ -13521,6 +13519,14 @@ msgstr "%s%s: tiempo de espera máximo para \"%s\" con %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: no es posible conectarse al transmisor" +#, fuzzy, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Señal %s recibida, cerrando WeeChat..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Señal %s recibida, cerrando WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Barra eliminada" diff --git a/po/fr.po b/po/fr.po index c2b6af51a..02f8b4748 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" -"PO-Revision-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" +"PO-Revision-Date: 2021-03-16 18:32+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -4980,6 +4980,14 @@ msgid "save configuration files when unloading plugins" msgstr "" "sauvegarder les fichiers de configuration lors du déchargement des extensions" +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"commande à exécuter lorsque le signal est reçu, plusieurs commandes peuvent " +"être séparées par des point-virgules (note : le contenu est évalué, voir /" +"help eval)" + msgid "FATAL: error initializing configuration options" msgstr "FATAL : erreur d'initialisation des options de configuration" @@ -5440,14 +5448,6 @@ msgstr "Couleurs WeeChat (en utilisation : %d, libres : %d) :" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal perdu, sortie de WeeChat..." -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Signal %s reçu, rechargement de la configuration..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Signal %s reçu, sortie de WeeChat..." - msgid "Mouse is enabled" msgstr "La souris est activée" @@ -15241,5 +15241,13 @@ msgstr "%s%s : délai d'attente dépassé pour \"%s\" avec %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s : impossible de se connecter : erreur inattendue (%d)" +#, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Signal %s reçu, rechargement de la configuration..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Signal %s reçu, sortie de WeeChat..." + #~ msgid "secured data: names and values" #~ msgstr "données sécurisées : noms et valeurs" diff --git a/po/hu.po b/po/hu.po index 28095d3d4..39e26d5fa 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -3750,6 +3750,12 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "beállítások mentése kilépéskor" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "felhasználónév az IRC szerveren" + #, fuzzy msgid "FATAL: error initializing configuration options" msgstr "szerver konfigurációs fájljának újraolvastatása" @@ -4166,14 +4172,6 @@ msgstr "" msgid "Terminal lost, exiting WeeChat..." msgstr "" -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "" - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "" - #, fuzzy msgid "Mouse is enabled" msgstr "a felhasználók le lettek tiltva" diff --git a/po/it.po b/po/it.po index f880ba632..0f568cb07 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -4502,6 +4502,14 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "salva i file di configurazione allo scaricamento dei plugin" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"comando eseguito all'avvio di WeeChat, dopo il caricamento dei plugin (nota: " +"il contenuto viene valutato, consultare /help eval)" + msgid "FATAL: error initializing configuration options" msgstr "FATALE: errore nell'inizializzazione delle opzioni di configurazione" @@ -4936,14 +4944,6 @@ msgstr "Colori di WeeChat (in uso: %d, rimaste: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminale perduto, chiusura di WeeChat..." -#, fuzzy, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Ricevuto segnale %s, chiusura di WeeChat..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Ricevuto segnale %s, chiusura di WeeChat..." - msgid "Mouse is enabled" msgstr "Mouse abilitato" @@ -13744,6 +13744,14 @@ msgstr "%s%s: timeout per \"%s\" con %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: impossibile connettersi al mittente" +#, fuzzy, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Ricevuto segnale %s, chiusura di WeeChat..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Ricevuto segnale %s, chiusura di WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Dati sicuri \"%s\" eliminati" diff --git a/po/ja.po b/po/ja.po index d2db601ea..a47074deb 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language-Team: Polish \n" @@ -4870,6 +4870,14 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "zapisuj pliki konfiguracyjne przy wyładowywaniu wtyczek" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"komenda wykonana kiedy WeeChat jest uruchamiany, po załadowaniu wtyczek " +"(uwaga: zawartość jest przetwarzana, zobacz /help eval)" + msgid "FATAL: error initializing configuration options" msgstr "KRYTYCZNE: błąd podczas inicjacji zmiennych konfiguracyjnych" @@ -5315,14 +5323,6 @@ msgstr "Kolory WeeChat (w użyciu: %d, zostało: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Utracono terminal, wychodzę z WeeChat..." -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Otrzymano sygnał %s, przeładowywuje konfigurację..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Otrzymano sygnał %s, wychodzę z WeeChat..." - msgid "Mouse is enabled" msgstr "Obsługa myszy włączona" @@ -14897,6 +14897,14 @@ msgstr "%s%s: przekroczono czas na \"%s\" z %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: nie można połączyć: niespodziewany błąd (%d)" +#, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Otrzymano sygnał %s, przeładowywuje konfigurację..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Otrzymano sygnał %s, wychodzę z WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Usunięto zabezpieczone dane \"%s\"" diff --git a/po/pt.po b/po/pt.po index d76ea3662..03d0f4e27 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -4756,6 +4756,14 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "guardar os ficheiros de configuração ao descarregar plugins" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"comando executado ao iniciar o WeeChat, depois de recarregar os plugins " +"(nota: o conteúdo é avaliado, ver /help eval)" + msgid "FATAL: error initializing configuration options" msgstr "FATAL: erro ao inicializar as opções de configuração" @@ -5204,14 +5212,6 @@ msgstr "Cores WeeChat (em uso: %d, livres: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal perdido, a sair do WeeChat..." -#, fuzzy, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Sinal %s recebido, a sair do WeeChat..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Sinal %s recebido, a sair do WeeChat..." - msgid "Mouse is enabled" msgstr "O rato está ativado" @@ -14398,6 +14398,14 @@ msgstr "%s%s: tempo limite de \"%s\" com %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: não foi possível conectar: erro inesperado (%d)" +#, fuzzy, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Sinal %s recebido, a sair do WeeChat..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Sinal %s recebido, a sair do WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Dados protegidos \"%s\" eliminados" diff --git a/po/pt_BR.po b/po/pt_BR.po index f803dbf15..81962c7c7 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-03-05 20:43+0100\n" "Last-Translator: Érico Nogueira \n" "Language-Team: weechat-dev \n" @@ -4382,6 +4382,14 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "salvar arquivos de configurações quando descarregar plugins" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" +"comando executado quando o WeeChat inicia, após o carregamento dos plugins " +"(nota: o conteúdo é avaliado, veja /help eval)" + msgid "FATAL: error initializing configuration options" msgstr "FATAL: erro inicializando opções de configuração" @@ -4783,14 +4791,6 @@ msgstr "Cores do WeeChat (em uso: %d, sobram: %d):" msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal perdido, saindo do WeeChat..." -#, fuzzy, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "Sinal %s recebido, saindo do WeeChat..." - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "Sinal %s recebido, saindo do WeeChat..." - msgid "Mouse is enabled" msgstr "Mouse está habilitado" @@ -12963,6 +12963,14 @@ msgstr "%s%s: tempo esgotado para \"%s\" com %s" msgid "%s%s: unable to connect: unexpected error (%d)" msgstr "%s%s: não foi possível conectar ao remetente" +#, fuzzy, c-format +#~ msgid "Signal %s received, reloading configuration..." +#~ msgstr "Sinal %s recebido, saindo do WeeChat..." + +#, c-format +#~ msgid "Signal %s received, exiting WeeChat..." +#~ msgstr "Sinal %s recebido, saindo do WeeChat..." + #, fuzzy #~ msgid "secured data: names and values" #~ msgstr "Dados seguros \"%s\" deletados" diff --git a/po/ru.po b/po/ru.po index 2ddfeef01..9a98d88c2 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -3779,6 +3779,12 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "сохранять конфигурационный файл при выходе" +#, fuzzy +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "ник, используемый на IRC сервере" + #, fuzzy msgid "FATAL: error initializing configuration options" msgstr "перезагрузить конфигурационный файл сервера" @@ -4199,14 +4205,6 @@ msgstr "" msgid "Terminal lost, exiting WeeChat..." msgstr "" -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "" - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "" - #, fuzzy msgid "Mouse is enabled" msgstr "команда users отключена" diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index b1b6bcb19..8313afe3b 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -78,6 +78,8 @@ SET(WEECHAT_SOURCES ./src/core/wee-secure-buffer.h ./src/core/wee-secure-config.c ./src/core/wee-secure-config.h +./src/core/wee-signal.c +./src/core/wee-signal.h ./src/core/wee-string.c ./src/core/wee-string.h ./src/core/wee-upgrade.c diff --git a/po/tr.po b/po/tr.po index 55af455bb..0053d1f68 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2021-02-06 15:55+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -3399,6 +3399,11 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "" +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" + msgid "FATAL: error initializing configuration options" msgstr "" @@ -3797,14 +3802,6 @@ msgstr "" msgid "Terminal lost, exiting WeeChat..." msgstr "" -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "" - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "" - msgid "Mouse is enabled" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index c5fa5c9e3..026df2f1b 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2021-03-14 14:00+0100\n" +"POT-Creation-Date: 2021-03-16 18:31+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -3388,6 +3388,11 @@ msgstr "" msgid "save configuration files when unloading plugins" msgstr "" +msgid "" +"command to execute when the signal is received, multiple commands can be " +"separated by semicolons (note: content is evaluated, see /help eval)" +msgstr "" + msgid "FATAL: error initializing configuration options" msgstr "" @@ -3786,14 +3791,6 @@ msgstr "" msgid "Terminal lost, exiting WeeChat..." msgstr "" -#, c-format -msgid "Signal %s received, reloading configuration..." -msgstr "" - -#, c-format -msgid "Signal %s received, exiting WeeChat..." -msgstr "" - msgid "Mouse is enabled" msgstr "" diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e1547653d..bbeaa9ce4 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -43,6 +43,7 @@ set(LIB_CORE_SRC wee-secure.c wee-secure.h wee-secure-buffer.c wee-secure-buffer.h wee-secure-config.c wee-secure-config.h + wee-signal.c wee-signal.h wee-string.c wee-string.h wee-upgrade.c wee-upgrade.h wee-upgrade-file.c wee-upgrade-file.h diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 62859c00f..29f7b2c61 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -67,6 +67,8 @@ lib_weechat_core_a_SOURCES = weechat.c \ wee-secure-buffer.h \ wee-secure-config.c \ wee-secure-config.h \ + wee-signal.c \ + wee-signal.h \ wee-string.c \ wee-string.h \ wee-upgrade.c \ diff --git a/src/core/hook/wee-hook-fd.c b/src/core/hook/wee-hook-fd.c index 262dcacde..5b598283f 100644 --- a/src/core/hook/wee-hook-fd.c +++ b/src/core/hook/wee-hook-fd.c @@ -32,7 +32,6 @@ #include "../wee-hook.h" #include "../wee-infolist.h" #include "../wee-log.h" -#include "../wee-util.h" #include "../../gui/gui-chat.h" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 49a904d24..353406825 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -5328,22 +5328,6 @@ command_reload_file (struct t_config_file *config_file) } } -/* - * Reloads all configuration files. - */ - -void -command_reload_files () -{ - struct t_config_file *ptr_config_file; - - for (ptr_config_file = config_files; ptr_config_file; - ptr_config_file = ptr_config_file->next_config) - { - command_reload_file (ptr_config_file); - } -} - /* * Callback for command "/reload": reloads a configuration file. */ @@ -5378,7 +5362,11 @@ COMMAND_CALLBACK(reload) } else { - command_reload_files (); + for (ptr_config_file = config_files; ptr_config_file; + ptr_config_file = ptr_config_file->next_config) + { + command_reload_file (ptr_config_file); + } } return WEECHAT_RC_OK; diff --git a/src/core/wee-command.h b/src/core/wee-command.h index 4d2214d14..07193a911 100644 --- a/src/core/wee-command.h +++ b/src/core/wee-command.h @@ -89,6 +89,5 @@ extern void command_version_display (struct t_gui_buffer *buffer, int send_to_buffer_as_input, int translated_string, int display_git_version); -extern void command_reload_files (); #endif /* WEECHAT_COMMAND_H */ diff --git a/src/core/wee-config.c b/src/core/wee-config.c index d265fba8d..d352d08bc 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -303,6 +303,14 @@ struct t_config_option *config_plugin_extension; struct t_config_option *config_plugin_path; struct t_config_option *config_plugin_save_config_on_unload; +/* config, signal section */ + +struct t_config_option *config_signal_sighup; +struct t_config_option *config_signal_sigquit; +struct t_config_option *config_signal_sigterm; +struct t_config_option *config_signal_sigusr1; +struct t_config_option *config_signal_sigusr2; + /* other */ int config_length_nick_prefix_suffix = 0; @@ -4566,6 +4574,63 @@ config_weechat_init_options () NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + /* signal */ + ptr_section = config_file_new_section (weechat_config_file, "signal", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); + if (!ptr_section) + { + config_file_free (weechat_config_file); + weechat_config_file = NULL; + return 0; + } + + config_signal_sighup = config_file_new_option ( + weechat_config_file, ptr_section, + "sighup", "string", + N_("command to execute when the signal is received, " + "multiple commands can be separated by semicolons " + "(note: content is evaluated, see /help eval)"), + NULL, 0, 0, + "${if:${info:weechat_headless}?/reload:/quit -yes}", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + config_signal_sigquit = config_file_new_option ( + weechat_config_file, ptr_section, + "sigquit", "string", + N_("command to execute when the signal is received, " + "multiple commands can be separated by semicolons " + "(note: content is evaluated, see /help eval)"), + NULL, 0, 0, "/quit -yes", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + config_signal_sigterm = config_file_new_option ( + weechat_config_file, ptr_section, + "sigterm", "string", + N_("command to execute when the signal is received, " + "multiple commands can be separated by semicolons " + "(note: content is evaluated, see /help eval)"), + NULL, 0, 0, "/quit -yes", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + config_signal_sigusr1 = config_file_new_option ( + weechat_config_file, ptr_section, + "sigusr1", "string", + N_("command to execute when the signal is received, " + "multiple commands can be separated by semicolons " + "(note: content is evaluated, see /help eval)"), + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + config_signal_sigusr2 = config_file_new_option ( + weechat_config_file, ptr_section, + "sigusr2", "string", + N_("command to execute when the signal is received, " + "multiple commands can be separated by semicolons " + "(note: content is evaluated, see /help eval)"), + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + /* bars */ ptr_section = config_file_new_section ( weechat_config_file, "bar", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index ba4068ee7..356641e6a 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -346,6 +346,12 @@ extern struct t_config_option *config_plugin_extension; extern struct t_config_option *config_plugin_path; extern struct t_config_option *config_plugin_save_config_on_unload; +extern struct t_config_option *config_signal_sighup; +extern struct t_config_option *config_signal_sigquit; +extern struct t_config_option *config_signal_sigterm; +extern struct t_config_option *config_signal_sigusr1; +extern struct t_config_option *config_signal_sigusr2; + extern int config_length_nick_prefix_suffix; extern int config_length_prefix_same_nick; extern int config_length_prefix_same_nick_middle; diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index 73525201e..71ec34bdd 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -147,7 +147,7 @@ debug_dump_cb (const void *pointer, void *data, */ void -debug_sigsegv () +debug_sigsegv_cb () { debug_dump (1); unhook_all (); diff --git a/src/core/wee-debug.h b/src/core/wee-debug.h index 617000973..f57bcf71f 100644 --- a/src/core/wee-debug.h +++ b/src/core/wee-debug.h @@ -24,7 +24,7 @@ struct t_gui_window_tree; -extern void debug_sigsegv (); +extern void debug_sigsegv_cb (); extern void debug_windows_tree (); extern void debug_memory (); extern void debug_hdata (); diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 12f713ce1..ad565a12a 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -35,8 +35,8 @@ #include "wee-hashtable.h" #include "wee-infolist.h" #include "wee-log.h" +#include "wee-signal.h" #include "wee-string.h" -#include "wee-util.h" #include "../gui/gui-chat.h" #include "../plugins/plugin.h" @@ -514,7 +514,7 @@ hook_set (struct t_hook *hook, const char *property, const char *value) if (!error || error[0]) { /* not a number? look for signal by name */ - number = util_signal_search (value); + number = signal_search_name (value); } if (number >= 0) { diff --git a/src/core/wee-signal.c b/src/core/wee-signal.c new file mode 100644 index 000000000..0765decf0 --- /dev/null +++ b/src/core/wee-signal.c @@ -0,0 +1,314 @@ +/* + * wee-signal.c - signal functions + * + * Copyright (C) 2021 Sébastien Helleu + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see . + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "weechat.h" +#include "wee-signal.h" +#include "wee-config.h" +#include "wee-debug.h" +#include "wee-eval.h" +#include "wee-hook.h" +#include "wee-input.h" +#include "wee-log.h" +#include "wee-string.h" +#include "../gui/gui-buffer.h" +#include "../plugins/plugin.h" + + +struct t_signal signal_list[] = +{ { SIGHUP, "hup" }, + { SIGINT, "int" }, + { SIGQUIT, "quit" }, + { SIGKILL, "kill" }, + { SIGTERM, "term" }, + { SIGUSR1, "usr1" }, + { SIGUSR2, "usr2" }, + { 0, NULL }, +}; + +volatile sig_atomic_t signal_sighup_count = 0; +volatile sig_atomic_t signal_sigquit_count = 0; +volatile sig_atomic_t signal_sigterm_count = 0; +volatile sig_atomic_t signal_sigusr1_count = 0; +volatile sig_atomic_t signal_sigusr2_count = 0; + + +/* + * Callback for system signal SIGHUP. + */ + +void +signal_sighup_cb () +{ + signal_sighup_count++; +} + +/* + * Callback for system signal SIGQUIT. + */ + +void +signal_sigquit_cb () +{ + signal_sigquit_count++; +} + +/* + * Callback for system signal SIGTERM. + */ + +void +signal_sigterm_cb () +{ + signal_sigterm_count++; +} + +/* + * Callback for system signal SIGUSR1. + */ + +void +signal_sigusr1_cb () +{ + signal_sigusr1_count++; +} + +/* + * Callback for system signal SIGUSR2. + */ + +void +signal_sigusr2_cb () +{ + signal_sigusr2_count++; +} + +/* + * Gets a signal index with a signal number; only some commonly used signal + * names are supported here (see declaration of signal_list[]). + * + * Returns the index of signal in structure string_signal, -1 if not found. + */ + +int +signal_search_number (int signal_number) +{ + int i; + + for (i = 0; signal_list[i].name; i++) + { + if (signal_list[i].signal == signal_number) + return i; + } + + /* signal not found */ + return -1; +} + +/* + * Gets a signal number with a name; only some commonly used signal names are + * supported here (see declaration of signal_list[]). + * + * Returns the signal number, -1 if not found. + */ + +int +signal_search_name (const char *name) +{ + int i; + + if (!name) + return -1; + + for (i = 0; signal_list[i].name; i++) + { + if (string_strcasecmp (signal_list[i].name, name) == 0) + return signal_list[i].signal; + } + + /* signal not found */ + return -1; +} + +/* + * Catches a system signal. + */ + +void +signal_catch (int signum, void (*handler)(int)) +{ + struct sigaction act; + + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = handler; + sigaction (signum, &act, NULL); +} + +/* + * Sends a WeeChat signal on a system signal received. + * + * Returns: + * WEECHAT_RC_OK: the WeeChat handler must be executed + * WEECHAT_RC_OK_EAT: signal eaten, the WeeChat handler must NOT be executed + */ + +int +signal_send_to_weechat (int signal_index) +{ + int rc; + char str_signal[32]; + + if (signal_index < 0) + return WEECHAT_RC_OK; + + snprintf (str_signal, sizeof (str_signal), + "signal_sig%s", signal_list[signal_index].name); + + rc = hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, NULL); + + return (rc == WEECHAT_RC_OK_EAT) ? WEECHAT_RC_OK_EAT : WEECHAT_RC_OK; +} + +/* + * Evaluates and executes the command bound to a signal. + */ + +void +signal_exec_command (int signal_index, const char *command) +{ + char *command_eval, **commands, **ptr_cmd, str_signal[32]; + struct t_gui_buffer *weechat_buffer; + + if (!command || !command[0]) + return; + + command_eval = eval_expression (command, NULL, NULL, NULL); + if (!command_eval) + return; + + if (command_eval[0]) + { + snprintf (str_signal, sizeof (str_signal), + "sig%s", signal_list[signal_index].name); + string_toupper (str_signal); + log_printf ("Signal %s received, executing command: %s", + str_signal, command_eval); + commands = string_split_command (command_eval, ';'); + if (commands) + { + weechat_buffer = gui_buffer_search_main (); + for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++) + { + (void) input_data (weechat_buffer, *ptr_cmd, NULL); + } + string_free_split_command (commands); + } + } + free (command_eval); +} + +/* + * Handles a specific signal received: + */ + +void +signal_handle_number (int signal_number, int count, const char *command) +{ + int i, signal_index, rc; + + if (count == 0) + return; + + signal_index = signal_search_number (signal_number); + if (signal_index < 0) + return; + + for (i = 0; i < count; i++) + { + rc = signal_send_to_weechat (signal_index); + if (rc == WEECHAT_RC_OK_EAT) + continue; + signal_exec_command (signal_index, command); + } +} + +/* + * Handles signals received: sends WeeChat signal and executes the configured + * command (is signal not eaten). + */ + +void +signal_handle () +{ + /* SIGUSR1 */ + signal_handle_number (SIGUSR1, signal_sigusr1_count, + CONFIG_STRING(config_signal_sigusr1)); + signal_sigusr1_count = 0; + + /* SIGUSR2 */ + signal_handle_number (SIGUSR2, signal_sigusr2_count, + CONFIG_STRING(config_signal_sigusr2)); + signal_sigusr2_count = 0; + + /* SIGHUP */ + signal_handle_number (SIGHUP, signal_sighup_count, + CONFIG_STRING(config_signal_sighup)); + signal_sighup_count = 0; + + /* SIGQUIT */ + signal_handle_number (SIGQUIT, signal_sigquit_count, + CONFIG_STRING(config_signal_sigquit)); + signal_sigquit_count = 0; + + /* SIGTERM */ + signal_handle_number (SIGTERM, signal_sigterm_count, + CONFIG_STRING(config_signal_sigterm)); + signal_sigterm_count = 0; +} + +/* + * Initializes signal. + */ + +void +signal_init () +{ + /* ignore some signals */ + signal_catch (SIGINT, SIG_IGN); + signal_catch (SIGPIPE, SIG_IGN); + + /* catch signals that can be customized */ + signal_catch (SIGHUP, &signal_sighup_cb); + signal_catch (SIGQUIT, &signal_sigquit_cb); + signal_catch (SIGTERM, &signal_sigterm_cb); + signal_catch (SIGUSR1, &signal_sigusr1_cb); + signal_catch (SIGUSR2, &signal_sigusr2_cb); + + /* in case of crash (oh no!) */ + signal_catch (SIGSEGV, &debug_sigsegv_cb); +} diff --git a/src/core/wee-signal.h b/src/core/wee-signal.h new file mode 100644 index 000000000..937986206 --- /dev/null +++ b/src/core/wee-signal.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021 Sébastien Helleu + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see . + */ + +#ifndef WEECHAT_SIGNAL_H +#define WEECHAT_SIGNAL_H + +struct t_signal +{ + int signal; /* signal number */ + char *name; /* signal name, eg "hup" for SIGHUP */ +}; + +extern struct t_signal signal_list[]; + +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_init (); + +#endif /* WEECHAT_SIGNAL_H */ diff --git a/src/core/wee-util.c b/src/core/wee-util.c index f04a7cbfa..61a095645 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -115,16 +115,6 @@ struct t_rlimit_resource rlimit_resource[] = }; #endif /* HAVE_SYS_RESOURCE_H */ -struct t_util_signal util_signals[] = -{ { "hup", SIGHUP }, - { "int", SIGINT }, - { "quit", SIGQUIT }, - { "kill", SIGKILL }, - { "term", SIGTERM }, - { "usr1", SIGUSR1 }, - { "usr2", SIGUSR2 }, - { NULL, 0 }, -}; /* * Sets resource limit. @@ -439,68 +429,6 @@ util_parse_delay (const char *string_delay, long default_factor) return delay * factor; } -/* - * Gets a signal number with a name; only some commonly used signal names are - * supported here (see declaration of util_signals[]). - * - * Returns the signal number, -1 if not found. - */ - -int -util_signal_search (const char *name) -{ - int i; - - if (!name) - return -1; - - for (i = 0; util_signals[i].name; i++) - { - if (string_strcasecmp (util_signals[i].name, name) == 0) - return util_signals[i].signal; - } - - /* signal not found */ - return -1; -} - -/* - * Gets a signal name with a signal number; only some commonly used signal - * names are supported here (see declaration of util_signals[]). - * - * Returns the pointer to the signal name, NULL if not found. - */ - -const char * -util_signal_search_number (int signal_number) -{ - int i; - - for (i = 0; util_signals[i].name; i++) - { - if (util_signals[i].signal == signal_number) - return util_signals[i].name; - } - - /* signal not found */ - return NULL; -} - -/* - * Catches a system signal. - */ - -void -util_catch_signal (int signum, void (*handler)(int)) -{ - struct sigaction act; - - sigemptyset (&act.sa_mask); - act.sa_flags = 0; - act.sa_handler = handler; - sigaction (signum, &act, NULL); -} - /* * Returns the path to a temporary directory, the first valid directory in * this list: diff --git a/src/core/wee-util.h b/src/core/wee-util.h index d38d3084b..e7cf2a5cd 100644 --- a/src/core/wee-util.h +++ b/src/core/wee-util.h @@ -31,14 +31,6 @@ struct t_rlimit_resource }; #endif /* HAVE_SYS_RESOURCE_H */ -struct t_util_signal -{ - char *name; /* name of signal */ - int signal; /* signal number */ -}; - -extern struct t_util_signal util_signals[]; - /* limits */ extern void util_setrlimit (); @@ -58,11 +50,6 @@ extern void util_get_time_diff (time_t time1, time_t time2, extern long util_parse_delay (const char *string_delay, long default_factor); -/* signal */ -extern int util_signal_search (const char *name); -extern const char *util_signal_search_number (int signal_number); -extern void util_catch_signal (int signum, void (*handler)(int)); - /* files/directories */ extern char *util_get_temp_dir(); extern int util_mkdir_home (const char *directory, int mode); diff --git a/src/core/weechat.c b/src/core/weechat.c index 4f18c90be..6d97bfe35 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -68,6 +68,7 @@ #include "wee-proxy.h" #include "wee-secure.h" #include "wee-secure-config.h" +#include "wee-signal.h" #include "wee-string.h" #include "wee-upgrade.h" #include "wee-utf8.h" @@ -99,7 +100,7 @@ time_t weechat_first_start_time = 0; /* start time (used by /uptime cmd) */ int weechat_upgrade_count = 0; /* number of /upgrade done */ struct timeval weechat_current_start_timeval; /* start time used to display */ /* duration of /upgrade */ -volatile sig_atomic_t weechat_quit = 0; /* = 1 if quit request from user */ +int weechat_quit = 0; /* = 1 if quit request from user */ volatile sig_atomic_t weechat_quit_signal = 0; /* signal received, */ /* WeeChat must quit */ volatile sig_atomic_t weechat_reload_signal = 0; /* signal received, */ @@ -688,36 +689,6 @@ weechat_locale_check () } } -/* - * Callback for system signal SIGHUP: reloads configuration. - */ - -void -weechat_sighup () -{ - weechat_reload_signal = SIGHUP; -} - -/* - * Callback for system signal SIGQUIT: quits WeeChat. - */ - -void -weechat_sigquit () -{ - weechat_quit_signal = SIGQUIT; -} - -/* - * Callback for system signal SIGTERM: quits WeeChat. - */ - -void -weechat_sigterm () -{ - weechat_quit_signal = SIGTERM; -} - /* * Shutdowns WeeChat. */ @@ -786,14 +757,7 @@ weechat_init (int argc, char *argv[], void (*gui_init_cb)()) weechat_first_start_time = time (NULL); /* initialize start time */ gettimeofday (&weechat_current_start_timeval, NULL); - /* catch signals */ - util_catch_signal (SIGINT, SIG_IGN); /* signal ignored */ - util_catch_signal (SIGPIPE, SIG_IGN); /* signal ignored */ - util_catch_signal (SIGSEGV, &debug_sigsegv); /* crash dump */ - util_catch_signal (SIGHUP, &weechat_sighup); /* exit WeeChat */ - util_catch_signal (SIGQUIT, &weechat_sigquit); /* exit WeeChat */ - util_catch_signal (SIGTERM, &weechat_sigterm); /* exit WeeChat */ - + signal_init (); /* initialize signals */ hdata_init (); /* initialize hdata */ hook_init (); /* initialize hooks */ debug_init (); /* hook signals for debug */ diff --git a/src/core/weechat.h b/src/core/weechat.h index c7eb4ba68..49614a804 100644 --- a/src/core/weechat.h +++ b/src/core/weechat.h @@ -109,7 +109,7 @@ extern int weechat_first_start; extern time_t weechat_first_start_time; extern struct timeval weechat_current_start_timeval; extern int weechat_upgrade_count; -extern volatile sig_atomic_t weechat_quit; +extern int weechat_quit; extern volatile sig_atomic_t weechat_quit_signal; extern volatile sig_atomic_t weechat_reload_signal; extern char *weechat_home; diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 15c95b8eb..4beec888b 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -35,9 +35,9 @@ #include "../../core/wee-config.h" #include "../../core/wee-hook.h" #include "../../core/wee-log.h" +#include "../../core/wee-signal.h" #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" -#include "../../core/wee-util.h" #include "../../core/wee-version.h" #include "../../plugins/plugin.h" #include "../gui-main.h" @@ -164,10 +164,9 @@ gui_main_init () struct t_gui_bar_window *ptr_bar_win; char title[256]; -#ifdef WEECHAT_HEADLESS /* allow Ctrl-C to quit WeeChat in headless mode */ - util_catch_signal (SIGINT, &gui_main_signal_sigint); -#endif /* WEECHAT_HEADLESS */ + if (weechat_headless) + signal_catch (SIGINT, &gui_main_signal_sigint); initscr (); @@ -264,30 +263,6 @@ gui_main_init () gui_window_set_bracketed_paste_mode (CONFIG_BOOLEAN(config_look_paste_bracketed)); } -/* - * Returns signal name with a signal number. - * - * Note: result must be freed after use. - */ - -char * -gui_main_get_signal_name (int signal_number) -{ - const char *signal_name; - char str_signal[32]; - - signal_name = util_signal_search_number (signal_number); - if (!signal_name) - return NULL; - - snprintf (str_signal, sizeof (str_signal), - "SIG%s", - signal_name); - string_toupper (str_signal); - - return strdup (str_signal); -} - /* * Callback for system signal SIGWINCH: refreshes screen. */ @@ -298,82 +273,6 @@ gui_main_signal_sigwinch () gui_signal_sigwinch_received = 1; } -/* - * Sends a WeeChat signal on a system signal received. - * - * Returns: - * WEECHAT_RC_OK: the WeeChat handler must be executed - * WEECHAT_RC_OK_EAT: signal eaten, the WeeChat handler must NOT be executed - */ - -int -gui_main_handle_signal (const char *signal_name) -{ - int rc; - char str_signal[32]; - - if (!signal_name) - return WEECHAT_RC_OK; - - snprintf (str_signal, sizeof (str_signal), "signal_%s", signal_name); - string_tolower (str_signal); - - rc = hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, NULL); - - return (rc == WEECHAT_RC_OK_EAT) ? WEECHAT_RC_OK_EAT : WEECHAT_RC_OK; -} - -/* - * Callback for signals received that will make WeeChat reload configuration. - */ - -void -gui_main_handle_reload_signal () -{ - char *signal_name; - - signal_name = gui_main_get_signal_name (weechat_reload_signal); - - if (gui_main_handle_signal (signal_name) != WEECHAT_RC_OK_EAT) - { - log_printf (_("Signal %s received, reloading configuration..."), - signal_name); - command_reload_files (); - } - - if (signal_name) - free (signal_name); - - weechat_reload_signal = 0; -} - -/* - * Callback for signals received that will make WeeChat quit. - */ - -void -gui_main_handle_quit_signals () -{ - char *signal_name; - - signal_name = gui_main_get_signal_name (weechat_quit_signal); - - if (gui_main_handle_signal (signal_name) != WEECHAT_RC_OK_EAT) - { - if (!weechat_quit) - { - log_printf (_("Signal %s received, exiting WeeChat..."), - signal_name); - (void) hook_signal_send ("quit", WEECHAT_HOOK_SIGNAL_STRING, NULL); - weechat_quit = 1; - } - } - - if (signal_name) - free (signal_name); - - weechat_quit_signal = 0; -} /* * Displays infos about ncurses lib. */ @@ -510,7 +409,7 @@ gui_main_loop () /* catch SIGWINCH signal: redraw screen */ if (!weechat_headless) - util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch); + signal_catch (SIGWINCH, &gui_main_signal_sigwinch); /* hook stdin (read keyboard) */ if (weechat_headless) @@ -566,10 +465,7 @@ gui_main_loop () hook_process_exec (); /* handle signals received */ - if (weechat_reload_signal > 0) - gui_main_handle_reload_signal (); - if (weechat_quit_signal > 0) - gui_main_handle_quit_signals (); + signal_handle (); } /* remove keyboard hook */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6f665f9ad..cfe5b50bd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,6 +34,7 @@ set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC unit/core/test-core-infolist.cpp unit/core/test-core-list.cpp unit/core/test-core-secure.cpp + unit/core/test-core-signal.cpp unit/core/test-core-string.cpp unit/core/test-core-url.cpp unit/core/test-core-utf8.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index a9d376a6b..b9f4acbe1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -31,6 +31,7 @@ lib_weechat_unit_tests_core_a_SOURCES = unit/core/test-core-arraylist.cpp \ unit/core/test-core-infolist.cpp \ unit/core/test-core-list.cpp \ unit/core/test-core-secure.cpp \ + unit/core/test-core-signal.cpp \ unit/core/test-core-string.cpp \ unit/core/test-core-url.cpp \ unit/core/test-core-utf8.cpp \ diff --git a/tests/tests.cpp b/tests/tests.cpp index 2ba5a2652..052f48096 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -69,6 +69,7 @@ IMPORT_TEST_GROUP(CoreHook); IMPORT_TEST_GROUP(CoreInfolist); IMPORT_TEST_GROUP(CoreList); IMPORT_TEST_GROUP(CoreSecure); +IMPORT_TEST_GROUP(CoreSignal); IMPORT_TEST_GROUP(CoreString); IMPORT_TEST_GROUP(CoreUrl); IMPORT_TEST_GROUP(CoreUtf8); diff --git a/tests/unit/core/test-core-signal.cpp b/tests/unit/core/test-core-signal.cpp new file mode 100644 index 000000000..9178588ba --- /dev/null +++ b/tests/unit/core/test-core-signal.cpp @@ -0,0 +1,161 @@ +/* + * test-core-signal.cpp - test util functions + * + * Copyright (C) 2021 Sébastien Helleu + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see . + */ + +#include "CppUTest/TestHarness.h" + +extern "C" +{ +#include +#include +#include +#include +#include "tests/tests.h" +#include "src/core/wee-signal.h" +} + +TEST_GROUP(CoreSignal) +{ +}; + +/* + * Tests functions: + * signal_search_number + */ + +TEST(CoreSignal, SearchNumber) +{ + int count, index; + + /* make tests fail if the signal_list structure is changed */ + for (count = 0; signal_list[count].name; count++) + { + } + LONGS_EQUAL(7, count); + + POINTERS_EQUAL(-1, signal_search_number (-1)); + POINTERS_EQUAL(-1, signal_search_number (999999999)); + + index = signal_search_number (SIGHUP); + LONGS_EQUAL(SIGHUP, signal_list[index].signal); + STRCMP_EQUAL("hup", signal_list[index].name); + + index = signal_search_number (SIGINT); + LONGS_EQUAL(SIGINT, signal_list[index].signal); + STRCMP_EQUAL("int", signal_list[index].name); + + index = signal_search_number (SIGQUIT); + LONGS_EQUAL(SIGQUIT, signal_list[index].signal); + STRCMP_EQUAL("quit", signal_list[index].name); + + index = signal_search_number (SIGKILL); + LONGS_EQUAL(SIGKILL, signal_list[index].signal); + STRCMP_EQUAL("kill", signal_list[index].name); + + index = signal_search_number (SIGTERM); + LONGS_EQUAL(SIGTERM, signal_list[index].signal); + STRCMP_EQUAL("term", signal_list[index].name); + + index = signal_search_number (SIGUSR1); + LONGS_EQUAL(SIGUSR1, signal_list[index].signal); + STRCMP_EQUAL("usr1", signal_list[index].name); + + index = signal_search_number (SIGUSR2); + LONGS_EQUAL(SIGUSR2, signal_list[index].signal); + STRCMP_EQUAL("usr2", signal_list[index].name); +} + +/* + * Tests functions: + * signal_search_name + */ + +TEST(CoreSignal, SearchName) +{ + LONGS_EQUAL(-1, signal_search_name (NULL)); + LONGS_EQUAL(-1, signal_search_name ("")); + LONGS_EQUAL(-1, signal_search_name ("signal_does_not_exist")); + + LONGS_EQUAL(SIGHUP, signal_search_name ("hup")); + LONGS_EQUAL(SIGHUP, signal_search_name ("HUP")); + LONGS_EQUAL(SIGINT, signal_search_name ("int")); + LONGS_EQUAL(SIGINT, signal_search_name ("INT")); + LONGS_EQUAL(SIGQUIT, signal_search_name ("quit")); + LONGS_EQUAL(SIGQUIT, signal_search_name ("QUIT")); + LONGS_EQUAL(SIGKILL, signal_search_name ("kill")); + LONGS_EQUAL(SIGKILL, signal_search_name ("KILL")); + LONGS_EQUAL(SIGTERM, signal_search_name ("term")); + LONGS_EQUAL(SIGTERM, signal_search_name ("TERM")); + LONGS_EQUAL(SIGUSR1, signal_search_name ("usr1")); + LONGS_EQUAL(SIGUSR1, signal_search_name ("USR1")); + LONGS_EQUAL(SIGUSR2, signal_search_name ("usr2")); + LONGS_EQUAL(SIGUSR2, signal_search_name ("USR2")); +} + +/* + * Tests functions: + * signal_catch + */ + +TEST(CoreSignal, Catch) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * signal_send_to_weechat + */ + +TEST(CoreSignal, SentToWeechat) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * signal_exec_command + */ + +TEST(CoreSignal, ExecCommand) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * signal_handle_number + */ + +TEST(CoreSignal, HandleNumber) +{ + /* TODO: write tests */ +} + + +/* + * Tests functions: + * signal_handle + */ + +TEST(CoreSignal, Handle) +{ + /* TODO: write tests */ +} diff --git a/tests/unit/core/test-core-util.cpp b/tests/unit/core/test-core-util.cpp index 41308703d..e78d2ba77 100644 --- a/tests/unit/core/test-core-util.cpp +++ b/tests/unit/core/test-core-util.cpp @@ -26,7 +26,6 @@ extern "C" #include #include #include -#include #include #include "src/core/wee-string.h" #include "src/core/wee-util.h" @@ -223,71 +222,6 @@ TEST(CoreUtil, ParseDelay) LONGS_EQUAL(123 * 1000 * 60 * 60, util_parse_delay ("123h", 1000)); } -/* - * Tests functions: - * util_signal_search - */ - -TEST(CoreUtil, SignalSearch) -{ - int count; - - /* make tests fail if the util_signals structure is changed */ - for (count = 0; util_signals[count].name; count++) - { - } - LONGS_EQUAL(7, count); - - LONGS_EQUAL(-1, util_signal_search (NULL)); - LONGS_EQUAL(-1, util_signal_search ("")); - LONGS_EQUAL(-1, util_signal_search ("signal_does_not_exist")); - - LONGS_EQUAL(SIGHUP, util_signal_search ("hup")); - LONGS_EQUAL(SIGINT, util_signal_search ("int")); - LONGS_EQUAL(SIGQUIT, util_signal_search ("quit")); - LONGS_EQUAL(SIGKILL, util_signal_search ("kill")); - LONGS_EQUAL(SIGTERM, util_signal_search ("term")); - LONGS_EQUAL(SIGUSR1, util_signal_search ("usr1")); - LONGS_EQUAL(SIGUSR2, util_signal_search ("usr2")); - - LONGS_EQUAL(SIGHUP, util_signal_search ("HUP")); - LONGS_EQUAL(SIGINT, util_signal_search ("INT")); - LONGS_EQUAL(SIGQUIT, util_signal_search ("QUIT")); - LONGS_EQUAL(SIGKILL, util_signal_search ("KILL")); - LONGS_EQUAL(SIGTERM, util_signal_search ("TERM")); - LONGS_EQUAL(SIGUSR1, util_signal_search ("USR1")); - LONGS_EQUAL(SIGUSR2, util_signal_search ("USR2")); -} - -/* - * Tests functions: - * util_signal_search_number - */ - -TEST(CoreUtil, SignalSearchNumber) -{ - POINTERS_EQUAL(NULL, util_signal_search_number (-1)); - POINTERS_EQUAL(NULL, util_signal_search_number (999999999)); - - STRCMP_EQUAL("hup", util_signal_search_number (SIGHUP)); - STRCMP_EQUAL("int", util_signal_search_number (SIGINT)); - STRCMP_EQUAL("quit", util_signal_search_number (SIGQUIT)); - STRCMP_EQUAL("kill", util_signal_search_number (SIGKILL)); - STRCMP_EQUAL("term", util_signal_search_number (SIGTERM)); - STRCMP_EQUAL("usr1", util_signal_search_number (SIGUSR1)); - STRCMP_EQUAL("usr2", util_signal_search_number (SIGUSR2)); -} - -/* - * Tests functions: - * util_catch_signal - */ - -TEST(CoreUtil, CatchSignal) -{ - /* TODO: write tests */ -} - /* * Tests functions: * util_mkdir_home