OSDN Git Service

[Refactor] #39962 files.c/h から signal-handlers.c/h を分離 / Separated signal-handlers...
authorHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 02:53:41 +0000 (11:53 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 02:53:41 +0000 (11:53 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/core.c
src/files.c
src/files.h
src/main-win.c
src/scores.c
src/signal-handlers.c [new file with mode: 0644]
src/signal-handlers.h [new file with mode: 0644]
src/util.c

index 6e1d23d..e935d52 100644 (file)
     <ClCompile Include="..\..\src\save.c" />\r
     <ClCompile Include="..\..\src\scores.c" />\r
     <ClCompile Include="..\..\src\selfinfo.c" />\r
+    <ClCompile Include="..\..\src\signal-handlers.c" />\r
     <ClCompile Include="..\..\src\snipe.c" />\r
     <ClCompile Include="..\..\src\sort.c" />\r
     <ClCompile Include="..\..\src\spells-diceroll.c" />\r
     <ClInclude Include="..\..\src\monster-dist-offsets.h" />\r
     <ClInclude Include="..\..\src\object-flavor.h" />\r
     <ClInclude Include="..\..\src\player-inventory.h" />\r
+    <ClInclude Include="..\..\src\signal-handlers.h" />\r
     <ClInclude Include="japanese.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
index e8bcd53..eb542d9 100644 (file)
     <ClCompile Include="..\..\src\horror-descriptions.c">
       <Filter>player</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\signal-handlers.c">
+      <Filter>io</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\horror-descriptions.h">
       <Filter>player</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\signal-handlers.h">
+      <Filter>io</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 19921f5..7415fad 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include "angband.h"
+#include "signal-handlers.h"
 #include "util.h"
 #include "core.h"
 #include "inet.h"
index f6dd6d7..14009dc 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include "angband.h"
+#include "signal-handlers.h"
 #include "util.h"
 #include "files.h"
 #include "core.h"
 #include "cmd-dump.h"
 #include "world.h"
 #include "player-inventory.h"
-#include "player-race.h"
-#include "player-status.h"
 #include "player-move.h"
-#include "player-class.h"
 #include "player-skill.h"
 #include "player-personality.h"
 #include "player-sex.h"
 #include "avatar.h"
 #include "shoot.h"
 #include "patron.h"
-#include "monster.h"
-#include "monster-process.h"
 #include "monster-status.h"
 #include "object-flavor.h"
 #include "object-hook.h"
-#include "realm.h"
 #include "realm-hex.h"
 #include "cmd-pet.h"
-#include "spells.h"
 #include "term.h"
 #include "view-mainwindow.h"
-#include "floor-events.h"
 #include "floor-town.h"
 #include "dungeon-file.h"
 #include "init.h"
 #include "monster-spell.h"
-#include "floor.h"
 #include "dungeon.h"
 #include "melee.h"
 #include "objectkind.h"
@@ -91,8 +83,6 @@ concptr ANGBAND_DIR_SAVE; //!< Savefiles for current characters (binary)
 concptr ANGBAND_DIR_USER; //!< User "preference" files (ascii) These files are rarely portable between platforms
 concptr ANGBAND_DIR_XTRA; //!< Various extra files (binary) These files are rarely portable between platforms
 
-s16b signal_count;             /* Hack -- Count interupts */
-
 /*
  * Buffer to hold the current savefile name
  * 'savefile' holds full path name. 'savefile_base' holds only base name.
@@ -5827,287 +5817,3 @@ errr counts_write(player_type *creature_ptr, int where, u32b count)
 
        return 0;
 }
-
-
-#ifdef HANDLE_SIGNALS
-
-#include <signal.h>
-
-/*!
- * @brief OSからのシグナルを受けてサスペンド状態に入る /
- * Handle signals -- suspend
- * @param sig 受け取ったシグナル
- * @details
- * Actually suspend the game, and then resume cleanly
- */
-static void handle_signal_suspend(int sig)
-{
-       (void)signal(sig, SIG_IGN);
-#ifdef SIGSTOP
-       Term_fresh();
-       Term_xtra(TERM_XTRA_ALIVE, 0);
-       (void)kill(0, SIGSTOP);
-       Term_xtra(TERM_XTRA_ALIVE, 1);
-       Term_redraw();
-       Term_fresh();
-#endif
-       (void)signal(sig, handle_signal_suspend);
-}
-
-
-/*!
- * todo ここにplayer_typeを追加すると関数ポインタ周りの収拾がつかなくなるので保留
- * @brief OSからのシグナルを受けて中断、終了する /
- * Handle signals -- simple (interrupt and quit)
- * @param sig 受け取ったシグナル
- * @details
- * <pre>
- * This function was causing a *huge* number of problems, so it has
- * been simplified greatly.  We keep a global variable which counts
- * the number of times the user attempts to kill the process, and
- * we commit suicide if the user does this a certain number of times.
- * We attempt to give "feedback" to the user as he approaches the
- * suicide thresh-hold, but without penalizing accidental keypresses.
- * To prevent messy accidents, we should reset this global variable
- * whenever the user enters a keypress, or something like that.
- * </pre>
- */
-static void handle_signal_simple(int sig)
-{
-       (void)signal(sig, SIG_IGN);
-       if (!current_world_ptr->character_generated || current_world_ptr->character_saved)
-               quit(NULL);
-
-       signal_count++;
-       if (p_ptr->is_dead)
-       {
-               (void)strcpy(p_ptr->died_from, _("強制終了", "Abortion"));
-               forget_lite(p_ptr->current_floor_ptr);
-               forget_view(p_ptr->current_floor_ptr);
-               clear_mon_lite(p_ptr->current_floor_ptr);
-               close_game(p_ptr);
-               quit(_("強制終了", "interrupt"));
-       }
-       else if (signal_count >= 5)
-       {
-               (void)strcpy(p_ptr->died_from, _("強制終了中", "Interrupting"));
-               forget_lite(p_ptr->current_floor_ptr);
-               forget_view(p_ptr->current_floor_ptr);
-               clear_mon_lite(p_ptr->current_floor_ptr);
-               p_ptr->playing = FALSE;
-               p_ptr->is_dead = TRUE;
-               p_ptr->leaving = TRUE;
-               close_game(p_ptr);
-               quit(_("強制終了", "interrupt"));
-       }
-       else if (signal_count >= 4)
-       {
-               Term_xtra(TERM_XTRA_NOISE, 0);
-               Term_erase(0, 0, 255);
-               Term_putstr(0, 0, -1, TERM_WHITE, _("熟慮の上の自殺!", "Contemplating suicide!"));
-               Term_fresh();
-       }
-       else if (signal_count >= 2)
-       {
-               Term_xtra(TERM_XTRA_NOISE, 0);
-       }
-
-       (void)signal(sig, handle_signal_simple);
-}
-
-
-/*!
- * todo ここにp_ptrを追加すると関数ポインタ周りの収拾がつかなくなるので保留
- * @brief OSからのシグナルを受けて強制終了する /
- * Handle signal -- abort, kill, etc
- * @param sig 受け取ったシグナル
- * @return なし
- * @details
- * <pre>
- * This function was causing a *huge* number of problems, so it has
- * been simplified greatly.  We keep a global variable which counts
- * the number of times the user attempts to kill the process, and
- * we commit suicide if the user does this a certain number of times.
- * We attempt to give "feedback" to the user as he approaches the
- * suicide thresh-hold, but without penalizing accidental keypresses.
- * To prevent messy accidents, we should reset this global variable
- * whenever the user enters a keypress, or something like that.
- * </pre>
- */
-static void handle_signal_abort(int sig)
-{
-       int wid, hgt;
-       Term_get_size(&wid, &hgt);
-
-       (void)signal(sig, SIG_IGN);
-       if (!current_world_ptr->character_generated || current_world_ptr->character_saved) quit(NULL);
-
-       forget_lite(p_ptr->current_floor_ptr);
-       forget_view(p_ptr->current_floor_ptr);
-       clear_mon_lite(p_ptr->current_floor_ptr);
-
-       Term_erase(0, hgt - 1, 255);
-       Term_putstr(0, hgt - 1, -1, TERM_RED,
-               _("恐ろしいソフトのバグが飛びかかってきた!", "A gruesome software bug LEAPS out at you!"));
-
-       Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ...", "Panic save..."));
-
-       exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----ゲーム異常終了----", "---- Panic Save and Abort Game ----"));
-       Term_fresh();
-
-       p_ptr->panic_save = 1;
-       (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
-
-       signals_ignore_tstp();
-
-       if (save_player(p_ptr))
-       {
-               Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
-       }
-       else
-       {
-               Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
-       }
-
-       Term_fresh();
-       quit(_("ソフトのバグ", "software bug"));
-}
-
-
-/*!
- * @brief OSからのSIGTSTPシグナルを無視する関数 /
- * Ignore SIGTSTP signals (keyboard suspend)
- * @return なし
- * @details
- */
-void signals_ignore_tstp(void)
-{
-#ifdef SIGTSTP
-       (void)signal(SIGTSTP, SIG_IGN);
-#endif
-}
-
-
-/*!
- * @brief OSからのSIGTSTPシグナルハンドラ /
- * Handle SIGTSTP signals (keyboard suspend)
- * @return なし
- * @details
- */
-void signals_handle_tstp(void)
-{
-#ifdef SIGTSTP
-       (void)signal(SIGTSTP, handle_signal_suspend);
-#endif
-}
-
-
-/*!
- * @brief OSからのシグナルハンドルを初期化する /
- * Prepare to handle the relevant signals
- * @return なし
- * @details
- */
-void signals_init(void)
-{
-#ifdef SIGHUP
-       (void)signal(SIGHUP, SIG_IGN);
-#endif
-
-#ifdef SIGTSTP
-       (void)signal(SIGTSTP, handle_signal_suspend);
-#endif
-
-#ifdef SIGINT
-       (void)signal(SIGINT, handle_signal_simple);
-#endif
-
-#ifdef SIGQUIT
-       (void)signal(SIGQUIT, handle_signal_simple);
-#endif
-
-#ifdef SIGFPE
-       (void)signal(SIGFPE, handle_signal_abort);
-#endif
-
-#ifdef SIGILL
-       (void)signal(SIGILL, handle_signal_abort);
-#endif
-
-#ifdef SIGTRAP
-       (void)signal(SIGTRAP, handle_signal_abort);
-#endif
-
-#ifdef SIGIOT
-       (void)signal(SIGIOT, handle_signal_abort);
-#endif
-
-#ifdef SIGKILL
-       (void)signal(SIGKILL, handle_signal_abort);
-#endif
-
-#ifdef SIGBUS
-       (void)signal(SIGBUS, handle_signal_abort);
-#endif
-
-#ifdef SIGSEGV
-       (void)signal(SIGSEGV, handle_signal_abort);
-#endif
-
-#ifdef SIGTERM
-       (void)signal(SIGTERM, handle_signal_abort);
-#endif
-
-#ifdef SIGPIPE
-       (void)signal(SIGPIPE, handle_signal_abort);
-#endif
-
-#ifdef SIGEMT
-       (void)signal(SIGEMT, handle_signal_abort);
-#endif
-
-#ifdef SIGDANGER
-       (void)signal(SIGDANGER, handle_signal_abort);
-#endif
-
-#ifdef SIGSYS
-       (void)signal(SIGSYS, handle_signal_abort);
-#endif
-
-#ifdef SIGXCPU
-       (void)signal(SIGXCPU, handle_signal_abort);
-#endif
-
-#ifdef SIGPWR
-       (void)signal(SIGPWR, handle_signal_abort);
-#endif
-}
-
-#else
-
-/*!
- * @brief ダミー /
- * Do nothing
- */
-void signals_ignore_tstp(void)
-{
-}
-
-
-/*!
- * @brief ダミー /
- * Do nothing
- */
-void signals_handle_tstp(void)
-{
-}
-
-
-/*!
- * @brief ダミー /
- * Do nothing
- */
-void signals_init(void)
-{
-}
-#endif
index 4dddc8a..b4173db 100644 (file)
@@ -19,8 +19,6 @@ extern concptr ANGBAND_DIR_SAVE;
 extern concptr ANGBAND_DIR_USER;
 extern concptr ANGBAND_DIR_XTRA;
 
-extern s16b signal_count;
-
 /* files.c */
 extern void safe_setuid_drop(void);
 extern void safe_setuid_grab(void);
@@ -41,9 +39,6 @@ extern void get_name(player_type *creature_ptr);
 extern void do_cmd_save_game(player_type *creature_ptr, int is_autosave);
 extern void do_cmd_save_and_exit(player_type *player_ptr);
 extern void exit_game_panic(player_type *creature_ptr);
-extern void signals_ignore_tstp(void);
-extern void signals_handle_tstp(void);
-extern void signals_init(void);
 extern errr get_rnd_line(concptr file_name, int entry, char *output);
 extern void print_tomb(player_type *dead_ptr);
 extern void show_info(player_type *creature_ptr);
index 1263008..9e9076f 100644 (file)
@@ -94,6 +94,7 @@
 */
 
 #include "angband.h"
+#include "signal-handlers.h"
 #include "util.h"
 #include "inet.h"
 #include "chuukei.h"
index cfe2c40..d083be9 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include "angband.h"
+#include "signal-handlers.h"
 #include "term.h"
 #include "util.h"
 #include "core.h"
diff --git a/src/signal-handlers.c b/src/signal-handlers.c
new file mode 100644 (file)
index 0000000..f75a8a8
--- /dev/null
@@ -0,0 +1,299 @@
+/*!
+ * @file signal-handlers.c
+ * @brief \83V\83O\83i\83\8b\83n\83\93\83h\83\89\82Ì\8aÇ\97\9d / Controlling signal handlers
+ * @date 2020/02/23
+ * @author Hourier
+ */
+
+#include "signal-handlers.h"
+#include "core.h"
+#include "save.h"
+#include "world.h"
+#include "term.h"
+#include "cmd/cmd-dump.h"
+#include "floor-events.h"
+
+s16b signal_count;             /* Hack -- Count interupts */
+
+#ifdef HANDLE_SIGNALS
+
+#include <signal.h>
+
+/*!
+ * @brief OS\82©\82ç\82Ì\83V\83O\83i\83\8b\82ð\8eó\82¯\82Ä\83T\83X\83y\83\93\83h\8fó\91Ô\82É\93ü\82é /
+ * Handle signals -- suspend
+ * @param sig \8eó\82¯\8eæ\82Á\82½\83V\83O\83i\83\8b
+ * @details
+ * Actually suspend the game, and then resume cleanly
+ */
+static void handle_signal_suspend(int sig)
+{
+       (void)signal(sig, SIG_IGN);
+#ifdef SIGSTOP
+       Term_fresh();
+       Term_xtra(TERM_XTRA_ALIVE, 0);
+       (void)kill(0, SIGSTOP);
+       Term_xtra(TERM_XTRA_ALIVE, 1);
+       Term_redraw();
+       Term_fresh();
+#endif
+       (void)signal(sig, handle_signal_suspend);
+}
+
+
+/*!
+ * todo \82±\82±\82Éplayer_type\82ð\92Ç\89Á\82·\82é\82Æ\8aÖ\90\94\83|\83C\83\93\83^\8eü\82è\82Ì\8eû\8fE\82ª\82Â\82©\82È\82­\82È\82é\82Ì\82Å\95Û\97¯
+ * @brief OS\82©\82ç\82Ì\83V\83O\83i\83\8b\82ð\8eó\82¯\82Ä\92\86\92f\81A\8fI\97¹\82·\82é /
+ * Handle signals -- simple (interrupt and quit)
+ * @param sig \8eó\82¯\8eæ\82Á\82½\83V\83O\83i\83\8b
+ * @details
+ * <pre>
+ * This function was causing a *huge* number of problems, so it has
+ * been simplified greatly.  We keep a global variable which counts
+ * the number of times the user attempts to kill the process, and
+ * we commit suicide if the user does this a certain number of times.
+ * We attempt to give "feedback" to the user as he approaches the
+ * suicide thresh-hold, but without penalizing accidental keypresses.
+ * To prevent messy accidents, we should reset this global variable
+ * whenever the user enters a keypress, or something like that.
+ * </pre>
+ */
+static void handle_signal_simple(int sig)
+{
+       (void)signal(sig, SIG_IGN);
+       if (!current_world_ptr->character_generated || current_world_ptr->character_saved)
+               quit(NULL);
+
+       signal_count++;
+       if (p_ptr->is_dead)
+       {
+               (void)strcpy(p_ptr->died_from, _("\8b­\90§\8fI\97¹", "Abortion"));
+               forget_lite(p_ptr->current_floor_ptr);
+               forget_view(p_ptr->current_floor_ptr);
+               clear_mon_lite(p_ptr->current_floor_ptr);
+               close_game(p_ptr);
+               quit(_("\8b­\90§\8fI\97¹", "interrupt"));
+       }
+       else if (signal_count >= 5)
+       {
+               (void)strcpy(p_ptr->died_from, _("\8b­\90§\8fI\97¹\92\86", "Interrupting"));
+               forget_lite(p_ptr->current_floor_ptr);
+               forget_view(p_ptr->current_floor_ptr);
+               clear_mon_lite(p_ptr->current_floor_ptr);
+               p_ptr->playing = FALSE;
+               p_ptr->is_dead = TRUE;
+               p_ptr->leaving = TRUE;
+               close_game(p_ptr);
+               quit(_("\8b­\90§\8fI\97¹", "interrupt"));
+       }
+       else if (signal_count >= 4)
+       {
+               Term_xtra(TERM_XTRA_NOISE, 0);
+               Term_erase(0, 0, 255);
+               Term_putstr(0, 0, -1, TERM_WHITE, _("\8fn\97\82Ì\8fã\82Ì\8e©\8eE\81I", "Contemplating suicide!"));
+               Term_fresh();
+       }
+       else if (signal_count >= 2)
+       {
+               Term_xtra(TERM_XTRA_NOISE, 0);
+       }
+
+       (void)signal(sig, handle_signal_simple);
+}
+
+
+/*!
+ * todo \82±\82±\82Ép_ptr\82ð\92Ç\89Á\82·\82é\82Æ\8aÖ\90\94\83|\83C\83\93\83^\8eü\82è\82Ì\8eû\8fE\82ª\82Â\82©\82È\82­\82È\82é\82Ì\82Å\95Û\97¯
+ * @brief OS\82©\82ç\82Ì\83V\83O\83i\83\8b\82ð\8eó\82¯\82Ä\8b­\90§\8fI\97¹\82·\82é /
+ * Handle signal -- abort, kill, etc
+ * @param sig \8eó\82¯\8eæ\82Á\82½\83V\83O\83i\83\8b
+ * @return \82È\82µ
+ * @details
+ * <pre>
+ * This function was causing a *huge* number of problems, so it has
+ * been simplified greatly.  We keep a global variable which counts
+ * the number of times the user attempts to kill the process, and
+ * we commit suicide if the user does this a certain number of times.
+ * We attempt to give "feedback" to the user as he approaches the
+ * suicide thresh-hold, but without penalizing accidental keypresses.
+ * To prevent messy accidents, we should reset this global variable
+ * whenever the user enters a keypress, or something like that.
+ * </pre>
+ */
+static void handle_signal_abort(int sig)
+{
+       int wid, hgt;
+       Term_get_size(&wid, &hgt);
+
+       (void)signal(sig, SIG_IGN);
+       if (!current_world_ptr->character_generated || current_world_ptr->character_saved) quit(NULL);
+
+       forget_lite(p_ptr->current_floor_ptr);
+       forget_view(p_ptr->current_floor_ptr);
+       clear_mon_lite(p_ptr->current_floor_ptr);
+
+       Term_erase(0, hgt - 1, 255);
+       Term_putstr(0, hgt - 1, -1, TERM_RED,
+               _("\8b°\82ë\82µ\82¢\83\\83t\83g\82Ì\83o\83O\82ª\94ò\82Ñ\82©\82©\82Á\82Ä\82«\82½\81I", "A gruesome software bug LEAPS out at you!"));
+
+       Term_putstr(45, hgt - 1, -1, TERM_RED, _("\8bÙ\8b}\83Z\81[\83u...", "Panic save..."));
+
+       exe_write_diary(p_ptr, DIARY_GAMESTART, 0, _("----\83Q\81[\83\80\88Ù\8fí\8fI\97¹----", "---- Panic Save and Abort Game ----"));
+       Term_fresh();
+
+       p_ptr->panic_save = 1;
+       (void)strcpy(p_ptr->died_from, _("(\8bÙ\8b}\83Z\81[\83u)", "(panic save)"));
+
+       signals_ignore_tstp();
+
+       if (save_player(p_ptr))
+       {
+               Term_putstr(45, hgt - 1, -1, TERM_RED, _("\8bÙ\8b}\83Z\81[\83u\90¬\8c÷\81I", "Panic save succeeded!"));
+       }
+       else
+       {
+               Term_putstr(45, hgt - 1, -1, TERM_RED, _("\8bÙ\8b}\83Z\81[\83u\8e¸\94s\81I", "Panic save failed!"));
+       }
+
+       Term_fresh();
+       quit(_("\83\\83t\83g\82Ì\83o\83O", "software bug"));
+}
+
+
+/*!
+ * @brief OS\82©\82ç\82ÌSIGTSTP\83V\83O\83i\83\8b\82ð\96³\8e\8b\82·\82é\8aÖ\90\94 /
+ * Ignore SIGTSTP signals (keyboard suspend)
+ * @return \82È\82µ
+ * @details
+ */
+void signals_ignore_tstp(void)
+{
+#ifdef SIGTSTP
+       (void)signal(SIGTSTP, SIG_IGN);
+#endif
+}
+
+
+/*!
+ * @brief OS\82©\82ç\82ÌSIGTSTP\83V\83O\83i\83\8b\83n\83\93\83h\83\89 /
+ * Handle SIGTSTP signals (keyboard suspend)
+ * @return \82È\82µ
+ * @details
+ */
+void signals_handle_tstp(void)
+{
+#ifdef SIGTSTP
+       (void)signal(SIGTSTP, handle_signal_suspend);
+#endif
+}
+
+
+/*!
+ * @brief OS\82©\82ç\82Ì\83V\83O\83i\83\8b\83n\83\93\83h\83\8b\82ð\8f\89\8aú\89»\82·\82é /
+ * Prepare to handle the relevant signals
+ * @return \82È\82µ
+ * @details
+ */
+void signals_init(void)
+{
+#ifdef SIGHUP
+       (void)signal(SIGHUP, SIG_IGN);
+#endif
+
+#ifdef SIGTSTP
+       (void)signal(SIGTSTP, handle_signal_suspend);
+#endif
+
+#ifdef SIGINT
+       (void)signal(SIGINT, handle_signal_simple);
+#endif
+
+#ifdef SIGQUIT
+       (void)signal(SIGQUIT, handle_signal_simple);
+#endif
+
+#ifdef SIGFPE
+       (void)signal(SIGFPE, handle_signal_abort);
+#endif
+
+#ifdef SIGILL
+       (void)signal(SIGILL, handle_signal_abort);
+#endif
+
+#ifdef SIGTRAP
+       (void)signal(SIGTRAP, handle_signal_abort);
+#endif
+
+#ifdef SIGIOT
+       (void)signal(SIGIOT, handle_signal_abort);
+#endif
+
+#ifdef SIGKILL
+       (void)signal(SIGKILL, handle_signal_abort);
+#endif
+
+#ifdef SIGBUS
+       (void)signal(SIGBUS, handle_signal_abort);
+#endif
+
+#ifdef SIGSEGV
+       (void)signal(SIGSEGV, handle_signal_abort);
+#endif
+
+#ifdef SIGTERM
+       (void)signal(SIGTERM, handle_signal_abort);
+#endif
+
+#ifdef SIGPIPE
+       (void)signal(SIGPIPE, handle_signal_abort);
+#endif
+
+#ifdef SIGEMT
+       (void)signal(SIGEMT, handle_signal_abort);
+#endif
+
+#ifdef SIGDANGER
+       (void)signal(SIGDANGER, handle_signal_abort);
+#endif
+
+#ifdef SIGSYS
+       (void)signal(SIGSYS, handle_signal_abort);
+#endif
+
+#ifdef SIGXCPU
+       (void)signal(SIGXCPU, handle_signal_abort);
+#endif
+
+#ifdef SIGPWR
+       (void)signal(SIGPWR, handle_signal_abort);
+#endif
+}
+
+#else
+
+/*!
+ * @brief \83_\83~\81[ /
+ * Do nothing
+ */
+void signals_ignore_tstp(void)
+{
+}
+
+
+/*!
+ * @brief \83_\83~\81[ /
+ * Do nothing
+ */
+void signals_handle_tstp(void)
+{
+}
+
+
+/*!
+ * @brief \83_\83~\81[ /
+ * Do nothing
+ */
+void signals_init(void)
+{
+}
+#endif
diff --git a/src/signal-handlers.h b/src/signal-handlers.h
new file mode 100644 (file)
index 0000000..f0b7c3b
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "angband.h"
+extern s16b signal_count;
+
+extern void signals_ignore_tstp(void);
+extern void signals_handle_tstp(void);
+extern void signals_init(void);
index 5be55b2..c330eb2 100644 (file)
@@ -11,6 +11,7 @@
  /* Purpose: Angband utilities -BEN- */
 
 #include "angband.h"
+#include "signal-handlers.h"
 #include "core.h"
 #include "term.h"
 #include "util.h"