diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-04 14:20:01 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-04 14:20:01 -0700 |
commit | 69446be1ee063771f2e0b498a50f9b0787ea70c7 (patch) | |
tree | be5ecf3a473052475218df605d350a204666c750 /proc.cpp | |
parent | cc90f9cf803bc4aba928b2a80be451d9b717c5f0 (diff) |
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
Diffstat (limited to 'proc.cpp')
-rw-r--r-- | proc.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -399,11 +399,10 @@ static void mark_process_status( const job_t *j, */ static void handle_child_status( pid_t pid, int status ) { - int found_proc = 0; + bool found_proc = false; const job_t *j=0; process_t *p=0; // char mess[MESS_SIZE]; - found_proc = 0; /* snprintf( mess, MESS_SIZE, @@ -413,7 +412,7 @@ static void handle_child_status( pid_t pid, int status ) */ job_iterator_t jobs; - while ((j = jobs.next())) + while (! found_proc && (j = jobs.next())) { process_t *prev=0; for( p=j->first_process; p; p=p->next ) @@ -442,7 +441,7 @@ static void handle_child_status( pid_t pid, int status ) kill(prev->pid,SIGPIPE); } } - found_proc = 1; + found_proc = true; break; } prev = p; @@ -466,15 +465,10 @@ static void handle_child_status( pid_t pid, int status ) } else { - //PCA INSTANCED_PARSER what is this? - block_t *c = NULL;//parser.current_block; + /* In an interactive session, tell the principal parser to skip all blocks we're executing so control-C returns control to the user. */ if( p && found_proc ) { - while( c ) - { - c->skip=1; - c=c->outer; - } + parser_t::skip_all_blocks(); } } } @@ -499,6 +493,7 @@ static void handle_child_status( pid_t pid, int status ) } +/* This is called from a signal handler */ void job_handle_signal ( int signal, siginfo_t *info, void *con ) { |