diff --git a/include/blc_command.h b/include/blc_command.h index 9a51760a69e40dfde7d36aa7b277f36779f868f8..37fca62bdf4cfd579ecc2c05f8946740a69e0dac 100644 --- a/include/blc_command.h +++ b/include/blc_command.h @@ -126,6 +126,11 @@ void blc_command_loop_init(long loop_period); int blc_command_loop_start(); void blc_command_loop_end(); + +/** Wait that the loop_thread launched by 'blc_command_loop_init' listining on keyboard stops ( i.e. 'quitting has been requested ).*/ +void blc_loop_wait_stop(); + + /** Stop a textual program * - Send a quitting message with the name of the app on stderr. * - Send 'q' and flush on stdout if it is a piped output diff --git a/src/blc_loop.cpp b/src/blc_loop.cpp index 6716e60d4064b8fb28c02e63c2aa2e7d87b39bc0..d3d8afea278d0959bd7e1cee32494d22a0800356 100644 --- a/src/blc_loop.cpp +++ b/src/blc_loop.cpp @@ -36,7 +36,6 @@ static struct timeval step_timer, profile_timer; static sem_t *blocking_semaphore=NULL; - type_blc_status blc_status=BLC_RUN; void blc_fprint_stats(FILE *file){ @@ -291,3 +290,8 @@ void blc_command_loop_end(){ intermediate_iteration++; blc_loop_iteration++; } + + +void blc_loop_wait_stop(){ + pthread_join(loop_thread, nullptr); +}