signal induced panictrace under curses
When panictrace feedback occurs due to catching a signal rather than controlled panic, the backtrace is useless when running the curses interface unless the terminal gets reset first. Let's just hope that the signal triggering a panictrace doesn't occur while resetting the terminal.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.468 $ $NHDT-Date: 1615158479 2021/03/07 23:07:59 $
|
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.469 $ $NHDT-Date: 1615304752 2021/03/09 15:45:52 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -828,6 +828,7 @@ curses: implement 'selectsaved', restore via menu of saved games
|
|||||||
curses: implement selecting menu items via mouse
|
curses: implement selecting menu items via mouse
|
||||||
curses: 'windowborders' can be set to 3 or 4 to suppress perm_invent borders
|
curses: 'windowborders' can be set to 3 or 4 to suppress perm_invent borders
|
||||||
to provide slightly more room for actual inventory info
|
to provide slightly more room for actual inventory info
|
||||||
|
curses: if panictrace is triggered, reset the terminal before giving backtrace
|
||||||
Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings"
|
Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings"
|
||||||
dialog box ("Preferences..." on OSX)
|
dialog box ("Preferences..." on OSX)
|
||||||
Qt: draw a border around each tile in the paper doll inventory; when BUC is
|
Qt: draw a border around each tile in the paper doll inventory; when BUC is
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ extern void curses_init_nhwindows(int* argcp, char** argv);
|
|||||||
extern void curses_player_selection(void);
|
extern void curses_player_selection(void);
|
||||||
extern void curses_askname(void);
|
extern void curses_askname(void);
|
||||||
extern void curses_get_nh_event(void);
|
extern void curses_get_nh_event(void);
|
||||||
|
extern void curses_uncurse_terminal(void);
|
||||||
extern void curses_exit_nhwindows(const char *str);
|
extern void curses_exit_nhwindows(const char *str);
|
||||||
extern void curses_suspend_nhwindows(const char *str);
|
extern void curses_suspend_nhwindows(const char *str);
|
||||||
extern void curses_resume_nhwindows(void);
|
extern void curses_resume_nhwindows(void);
|
||||||
|
|||||||
24
src/end.c
24
src/end.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 end.c $NHDT-Date: 1612316744 2021/02/03 01:45:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.220 $ */
|
/* NetHack 3.7 end.c $NHDT-Date: 1615304753 2021/03/09 15:45:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.222 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -109,6 +109,20 @@ panictrace_handler(int sig_unused UNUSED)
|
|||||||
{
|
{
|
||||||
#define SIG_MSG "\nSignal received.\n"
|
#define SIG_MSG "\nSignal received.\n"
|
||||||
int f2;
|
int f2;
|
||||||
|
|
||||||
|
#ifdef CURSES_GRAPHICS
|
||||||
|
if (iflags.window_inited && WINDOWPORT("curses")) {
|
||||||
|
extern void curses_uncurse_terminal(void); /* wincurs.h */
|
||||||
|
|
||||||
|
/* it is risky calling this during a program-terminating signal,
|
||||||
|
but without it the subsequent backtrace is useless because
|
||||||
|
that ends up being scrawled all over the screen; call is
|
||||||
|
here rather than in NH_abort() because panic() calls both
|
||||||
|
exit_nhwindows(), which makes this same call under curses,
|
||||||
|
then NH_abort() and we don't want to call this twice */
|
||||||
|
curses_uncurse_terminal();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
f2 = (int) write(2, SIG_MSG, sizeof SIG_MSG - 1);
|
f2 = (int) write(2, SIG_MSG, sizeof SIG_MSG - 1);
|
||||||
nhUse(f2); /* what could we do if write to fd#2 (stderr) fails */
|
nhUse(f2); /* what could we do if write to fd#2 (stderr) fails */
|
||||||
@@ -156,8 +170,10 @@ NH_abort(void)
|
|||||||
{
|
{
|
||||||
int gdb_prio = SYSOPT_PANICTRACE_GDB;
|
int gdb_prio = SYSOPT_PANICTRACE_GDB;
|
||||||
int libc_prio = SYSOPT_PANICTRACE_LIBC;
|
int libc_prio = SYSOPT_PANICTRACE_LIBC;
|
||||||
static boolean aborting = FALSE;
|
static volatile boolean aborting = FALSE;
|
||||||
|
|
||||||
|
/* don't execute this code recursively if a second abort is requested
|
||||||
|
while this routine or the code it calls is executing */
|
||||||
if (aborting)
|
if (aborting)
|
||||||
return;
|
return;
|
||||||
aborting = TRUE;
|
aborting = TRUE;
|
||||||
@@ -553,8 +569,8 @@ fixup_death(int how)
|
|||||||
DISABLE_WARNING_FORMAT_NONLITERAL
|
DISABLE_WARNING_FORMAT_NONLITERAL
|
||||||
|
|
||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
void panic
|
void
|
||||||
VA_DECL(const char *, str)
|
panic VA_DECL(const char *, str)
|
||||||
{
|
{
|
||||||
VA_START(str);
|
VA_START(str);
|
||||||
VA_INIT(str, char *);
|
VA_INIT(str, char *);
|
||||||
|
|||||||
@@ -299,6 +299,19 @@ curses_get_nh_event(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* restore terminal state; extracted from curses_exit_nhwindows() */
|
||||||
|
void
|
||||||
|
curses_uncurse_terminal(void)
|
||||||
|
{
|
||||||
|
/* also called by panictrace_handler(), a signal handler, so somewhat
|
||||||
|
iffy in that situation; but without this, newlines behave as raw
|
||||||
|
line feeds so subseqent backtrace gets scrawled all over the screen
|
||||||
|
and is nearly useless */
|
||||||
|
curses_cleanup();
|
||||||
|
curs_set(orig_cursor);
|
||||||
|
endwin();
|
||||||
|
}
|
||||||
|
|
||||||
/* Exits the window system. This should dismiss all windows,
|
/* Exits the window system. This should dismiss all windows,
|
||||||
except the "window" used for raw_print(). str is printed if possible.
|
except the "window" used for raw_print(). str is printed if possible.
|
||||||
*/
|
*/
|
||||||
@@ -311,9 +324,8 @@ curses_exit_nhwindows(const char *str)
|
|||||||
curses_destroy_nhwindow(MESSAGE_WIN);
|
curses_destroy_nhwindow(MESSAGE_WIN);
|
||||||
curs_destroy_all_wins();
|
curs_destroy_all_wins();
|
||||||
|
|
||||||
curses_cleanup();
|
curses_uncurse_terminal();
|
||||||
curs_set(orig_cursor);
|
|
||||||
endwin();
|
|
||||||
iflags.window_inited = 0;
|
iflags.window_inited = 0;
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
raw_print(str);
|
raw_print(str);
|
||||||
|
|||||||
Reference in New Issue
Block a user