Print stack trace when execting due to fatal problem or bug

darcs-hash:20070121150341-ac50b-66b86014963568bf402a76d5beb7c1d4e188c5f7.gz
This commit is contained in:
axel 2007-01-22 01:03:41 +10:00
parent 66c045c439
commit 98a6c491b1
5 changed files with 19 additions and 12 deletions

View file

@ -704,7 +704,7 @@ wchar_t *escape( const wchar_t *in,
if( !in ) if( !in )
{ {
debug( 0, L"%s called with null input", __func__ ); debug( 0, L"%s called with null input", __func__ );
exit(1); FATAL_EXIT();
} }
out = malloc( sizeof(wchar_t)*(wcslen(in)*4 + 1)); out = malloc( sizeof(wchar_t)*(wcslen(in)*4 + 1));

View file

@ -91,9 +91,9 @@ extern wchar_t *program_name;
} }
/** /**
Cause fish to crash. If supported, print a backtrace first. Pause for input, then exit the program. If supported, print a backtrace first.
*/ */
#define CRASH() \ #define FATAL_EXIT() \
{ \ { \
char c; \ char c; \
show_stackframe(); \ show_stackframe(); \
@ -111,7 +111,7 @@ extern wchar_t *program_name;
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \ L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
__LINE__, \ __LINE__, \
__FILE__ ); \ __FILE__ ); \
CRASH(); \ FATAL_EXIT(); \
} }
/** /**

6
exec.c
View file

@ -220,7 +220,7 @@ void free_fd( io_data_t *io, int fd )
FD_ERROR, FD_ERROR,
fd ); fd );
wperror( L"dup" ); wperror( L"dup" );
exit(1); FATAL_EXIT();
} }
} }
else else
@ -515,7 +515,7 @@ static void launch_process( process_t *p )
errno = err; errno = err;
wperror( L"execve" ); wperror( L"execve" );
exit(1); FATAL_EXIT();
} }
@ -761,7 +761,7 @@ static pid_t exec_fork()
debug( 0, FORK_ERROR ); debug( 0, FORK_ERROR );
wperror (L"fork"); wperror (L"fork");
exit( 1 ); FATAL_EXIT();
} }

View file

@ -2588,7 +2588,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
debug( 0, debug( 0,
_(L"End of block mismatch. Program terminating.") ); _(L"End of block mismatch. Program terminating.") );
bugreport(); bugreport();
exit(1); FATAL_EXIT();
break; break;
} }

View file

@ -557,7 +557,7 @@ void signal_set_handlers()
if( sigaction( SIGINT, &act, 0) ) if( sigaction( SIGINT, &act, 0) )
{ {
wperror( L"sigaction" ); wperror( L"sigaction" );
exit(1); FATAL_EXIT();
} }
act.sa_sigaction = &handle_chld; act.sa_sigaction = &handle_chld;
@ -565,7 +565,7 @@ void signal_set_handlers()
if( sigaction( SIGCHLD, &act, 0) ) if( sigaction( SIGCHLD, &act, 0) )
{ {
wperror( L"sigaction" ); wperror( L"sigaction" );
exit(1); FATAL_EXIT();
} }
#ifdef SIGWINCH #ifdef SIGWINCH
@ -574,7 +574,7 @@ void signal_set_handlers()
if( sigaction( SIGWINCH, &act, 0 ) ) if( sigaction( SIGWINCH, &act, 0 ) )
{ {
wperror( L"sigaction" ); wperror( L"sigaction" );
exit(1); FATAL_EXIT();
} }
#endif #endif
@ -583,7 +583,7 @@ void signal_set_handlers()
if( sigaction( SIGHUP, &act, 0 ) ) if( sigaction( SIGHUP, &act, 0 ) )
{ {
wperror( L"sigaction" ); wperror( L"sigaction" );
exit(1); FATAL_EXIT();
} }
} }
@ -661,6 +661,13 @@ void signal_unblock()
block_count--; block_count--;
if( block_count < 0 )
{
debug( 0, _( L"Signal block mismatch" ) );
bugreport();
FATAL_EXIT();
}
if( !block_count ) if( !block_count )
{ {
sigfillset( &chldset ); sigfillset( &chldset );