diff options
author | axel <axel@liljencrantz.se> | 2005-09-25 05:52:42 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2005-09-25 05:52:42 +1000 |
commit | 0085156a05378be50cc2b37654d678a275f743ed (patch) | |
tree | 4cbcd1adc0a71a13b0a45ebd0df265d1cb04e9be | |
parent | bee8f2c72118fecebd383efc5857ae1943d52c35 (diff) |
Fix crash bug when user presses ^C
darcs-hash:20050924195242-ac50b-f94edc21751e0202808f44bf732e050173a82fea.gz
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | proc.c | 37 |
2 files changed, 15 insertions, 25 deletions
@@ -7,7 +7,8 @@ * parser.c (pares_job_main_loop): Fix memory leak on parse error in pipeline * common.h, common.c: Make DEBUG_LEVEL constant into debug_level runtime configurable variable - + + * proc.h (handle_child_status): Fix crash bug when user presses ^C 2005-09-23 Axel Liljencrantz <axel@liljencrantz.se> @@ -512,13 +512,6 @@ static void mark_process_status( job_t *j, if (WIFSTOPPED (status)) { p->stopped = 1; -// fwprintf( stderr, L"Proc %d (%ls) stopped\n", p->pid, p->actual_cmd ); - -/* sprintf( mess, - "%ls (%d): Process stopped\n", - j->command, - (int) p->pid ); - write( 2, mess, strlen(mess) );*/ } else { @@ -529,8 +522,9 @@ static void mark_process_status( job_t *j, (! WIFSIGNALED( status )) ) { /* This should never be reached */ - char mess[128]; - sprintf( mess, + char mess[MESS_SIZE]; + snprintf( mess, + MESS_SIZE, "Process %d exited abnormally\n", (int) p->pid ); @@ -546,9 +540,9 @@ static void mark_process_status( job_t *j, static void handle_child_status( pid_t pid, int status ) { int found_proc = 0; - job_t *j; - process_t *p; - char mess[MESS_SIZE]; + job_t *j=0; + process_t *p=0; +// char mess[MESS_SIZE]; found_proc = 0; /* snprintf( mess, @@ -612,19 +606,14 @@ static void handle_child_status( pid_t pid, int status ) else { block_t *c = current_block; - - snprintf( mess, - MESS_SIZE, - "Process %ls from job %ls exited through signal, breaking loops\n", - p->actual_cmd, - j->command ); - write( 2, mess, strlen(mess )); - - while( c ) + if( p && found_proc ) { - c->skip=1; - c=c->outer; - } + while( c ) + { + c->skip=1; + c=c->outer; + } + } } } |