From: Jes.Sorensen@redhat.com
To: kwolf@redhat.com
Cc: armbru@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qemu-progress.c: printf isn't signal safe
Date: Thu, 28 Apr 2011 12:00:13 +0200 [thread overview]
Message-ID: <1303984813-20169-1-git-send-email-Jes.Sorensen@redhat.com> (raw)
From: Jes Sorensen <Jes.Sorensen@redhat.com>
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 <Jes.Sorensen@redhat.com>
---
qemu-progress.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/qemu-progress.c b/qemu-progress.c
index e1feb89..27a2310 100644
--- a/qemu-progress.c
+++ b/qemu-progress.c
@@ -32,6 +32,7 @@ struct progress_state {
float current;
float last_print;
float min_skip;
+ int print_pending;
void (*print)(void);
void (*end)(void);
};
@@ -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);
+ state.print_pending = 1;
}
#endif
static void progress_dummy_print(void)
{
+ if (state.print_pending) {
+ fprintf(stderr, " (%3.2f/100%%)\n", state.current);
+ state.print_pending = 0;
+ }
}
static void progress_dummy_end(void)
--
1.7.4.4
next reply other threads:[~2011-04-28 10:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-28 10:00 Jes.Sorensen [this message]
2011-04-28 11:25 ` [Qemu-devel] [PATCH] qemu-progress.c: printf isn't signal safe Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303984813-20169-1-git-send-email-Jes.Sorensen@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).