Commit 2ab3cb8c authored by Jes Sorensen's avatar Jes Sorensen Committed by Kevin Wolf
Browse files

qemu-progress.c: printf isn't signal safe



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: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent ab719827
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment