[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/6] qemu-progress.c: printf isn't signal safe
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 5/6] qemu-progress.c: printf isn't signal safe |
Date: |
Tue, 3 May 2011 13:08:25 +0200 |
From: Jes Sorensen <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-progress.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/qemu-progress.c b/qemu-progress.c
index e1feb89..a4894c0 100644
--- a/qemu-progress.c
+++ b/qemu-progress.c
@@ -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)
--
1.7.2.3
- [Qemu-devel] [PULL 0/6] Block patches, Kevin Wolf, 2011/05/03
- [Qemu-devel] [PATCH 1/6] qemu-img resize: Fix option parsing, Kevin Wolf, 2011/05/03
- [Qemu-devel] [PATCH 2/6] atapi: Move comment to proper place, Kevin Wolf, 2011/05/03
- [Qemu-devel] [PATCH 3/6] atapi: Explain why we need a 'media not present' state, Kevin Wolf, 2011/05/03
- [Qemu-devel] [PATCH 5/6] qemu-progress.c: printf isn't signal safe,
Kevin Wolf <=
- [Qemu-devel] [PATCH 4/6] ide/atapi: fix set but unused, Kevin Wolf, 2011/05/03
- [Qemu-devel] [PATCH 6/6] NBD: Avoid leaking a couple of strings when the NBD device is closed, Kevin Wolf, 2011/05/03
- Re: [Qemu-devel] [PULL 0/6] Block patches, Anthony Liguori, 2011/05/03