Signal handling cleanup and improved safety

Fixes issue where you couldn't control-C out of a loop (https://github.com/ridiculousfish/fishfish/issues/13)
Also stops doing memory allocation in the signal handler (oops) https://github.com/ridiculousfish/fishfish/issues/27
This commit is contained in:
ridiculousfish
2012-06-04 14:20:01 -07:00
parent cc90f9cf80
commit 69446be1ee
9 changed files with 104 additions and 57 deletions

View File

@@ -371,14 +371,35 @@ parser_t::parser_t(enum parser_type_t type, bool errors) :
}
/* A pointer to the principal parser (which is a static local) */
static parser_t *s_principal_parser = NULL;
parser_t &parser_t::principal_parser(void)
{
ASSERT_IS_NOT_FORKED_CHILD();
ASSERT_IS_MAIN_THREAD();
static parser_t parser(PARSER_TYPE_GENERAL, true);
if (! s_principal_parser)
{
s_principal_parser = &parser;
}
return parser;
}
void parser_t::skip_all_blocks(void)
{
/* Tell all blocks to skip */
if (s_principal_parser)
{
block_t *c = s_principal_parser->current_block;
while( c )
{
c->skip = true;
c = c->outer;
}
}
}
/**
Return the current number of block nestings
*/