MCPcopy Create free account
hub / github.com/NetHack/NetHack / panictrace_handler

Function panictrace_handler

src/report.c:599–622  ·  view source on GitHub ↗

called as signal() handler, so sent at least one arg */ ARGUSED*/

Source from the content-addressed store, hash-verified

597/* called as signal() handler, so sent at least one arg */
598/*ARGUSED*/
599void
600panictrace_handler(int sig_unused UNUSED)
601{
602#define SIG_MSG "\nSignal received.\n"
603 int f2;
604
605# ifdef CURSES_GRAPHICS
606 if (iflags.window_inited && WINDOWPORT(curses)) {
607 extern void curses_uncurse_terminal(void); /* wincurs.h */
608
609 /* it is risky calling this during a program-terminating signal,
610 but without it the subsequent backtrace is useless because
611 that ends up being scrawled all over the screen; call is
612 here rather than in NH_abort() because panic() calls both
613 exit_nhwindows(), which makes this same call under curses,
614 then NH_abort() and we don't want to call this twice */
615 curses_uncurse_terminal();
616 }
617# endif
618
619 f2 = (int) write(2, SIG_MSG, sizeof SIG_MSG - 1);
620 nhUse(f2); /* what could we do if write to fd#2 (stderr) fails */
621 NH_abort(NULL); /* ... and we're already in the process of quitting? */
622}
623
624void
625panictrace_setsignals(boolean set)

Callers

nothing calls this directly

Calls 3

curses_uncurse_terminalFunction · 0.85
writeFunction · 0.85
NH_abortFunction · 0.85

Tested by

no test coverage detected