qemu-progress.c: printf isn't signal safe
PATCH v2 1/1 qemu-progress.c: printf isn't signal safe
From: Jes Sorensen <[email protected]>
Change the signal handling to indicate a signal is pending, rather then printing directly from the signal handler.
In addition make the signal prints go to stderr, rather than stdout.
--- qemu-progress.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
qemu-progress.c +6 -1
@@ -37,6 +37,7 @@ struct progress_state { };static struct progress_state state; +static volatile sig_atomic_t print_pending;/* * Simple progress print function.
@@ -63,12 +64,16 @@ static void progress_simple_init(void)#ifdef CONFIG_POSIX static void sigusr_print (int signal) { -printf (" (%3.2f/100%%)\n" , state.current); + print_pending =1 ; }#endif static void progress_dummy_print (void ) { +if (print_pending) { +fprintf (stderr," (%3.2f/100%%)\n" , state.current); + print_pending =0 ; + } }static void progress_dummy_end (void )
Signature · 1 line
1.7.4.4
Quoted 6 lines · [email protected] writes:
From: Jes Sorensen <[email protected]>
Change the signal handling to indicate a signal is pending, rather then printing directly from the signal handler.
In addition make the signal prints go to stderr, rather than stdout.
Looks good now.
Kevin Wolf
AppliedAm 28.04.2011 13:58, schrieb [email protected]:
Quoted 8 lines
From: Jes Sorensen <[email protected]>
Change the signal handling to indicate a signal is pending, rather then printing directly from the signal handler.
In addition make the signal prints go to stderr, rather than stdout.
Signed-off-by Jes Sorensen <[email protected]>
Thanks, applied to the block branch.
Kevin