diff --git a/common.c b/common.c index 0b7a26aed..16e8b09b9 100644 --- a/common.c +++ b/common.c @@ -704,7 +704,7 @@ wchar_t *escape( const wchar_t *in, if( !in ) { debug( 0, L"%s called with null input", __func__ ); - exit(1); + FATAL_EXIT(); } out = malloc( sizeof(wchar_t)*(wcslen(in)*4 + 1)); diff --git a/common.h b/common.h index f5603d418..f362f7f2c 100644 --- a/common.h +++ b/common.h @@ -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; \ 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", \ __LINE__, \ __FILE__ ); \ - CRASH(); \ + FATAL_EXIT(); \ } /** diff --git a/exec.c b/exec.c index f99cf6790..1e31699fc 100644 --- a/exec.c +++ b/exec.c @@ -220,7 +220,7 @@ void free_fd( io_data_t *io, int fd ) FD_ERROR, fd ); wperror( L"dup" ); - exit(1); + FATAL_EXIT(); } } else @@ -515,7 +515,7 @@ static void launch_process( process_t *p ) errno = err; wperror( L"execve" ); - exit(1); + FATAL_EXIT(); } @@ -761,7 +761,7 @@ static pid_t exec_fork() debug( 0, FORK_ERROR ); wperror (L"fork"); - exit( 1 ); + FATAL_EXIT(); } diff --git a/parser.c b/parser.c index 41b0bc8cf..8a8525870 100644 --- a/parser.c +++ b/parser.c @@ -2588,7 +2588,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type ) debug( 0, _(L"End of block mismatch. Program terminating.") ); bugreport(); - exit(1); + FATAL_EXIT(); break; } diff --git a/signal.c b/signal.c index 40e23f79a..b5271e0a1 100644 --- a/signal.c +++ b/signal.c @@ -557,7 +557,7 @@ void signal_set_handlers() if( sigaction( SIGINT, &act, 0) ) { wperror( L"sigaction" ); - exit(1); + FATAL_EXIT(); } act.sa_sigaction = &handle_chld; @@ -565,7 +565,7 @@ void signal_set_handlers() if( sigaction( SIGCHLD, &act, 0) ) { wperror( L"sigaction" ); - exit(1); + FATAL_EXIT(); } #ifdef SIGWINCH @@ -574,7 +574,7 @@ void signal_set_handlers() if( sigaction( SIGWINCH, &act, 0 ) ) { wperror( L"sigaction" ); - exit(1); + FATAL_EXIT(); } #endif @@ -583,7 +583,7 @@ void signal_set_handlers() if( sigaction( SIGHUP, &act, 0 ) ) { wperror( L"sigaction" ); - exit(1); + FATAL_EXIT(); } } @@ -661,6 +661,13 @@ void signal_unblock() block_count--; + if( block_count < 0 ) + { + debug( 0, _( L"Signal block mismatch" ) ); + bugreport(); + FATAL_EXIT(); + } + if( !block_count ) { sigfillset( &chldset );