* [Qemu-devel] [PATCH] flush stdout after printing usage()
@ 2009-01-28 18:47 Riku Voipio
2009-01-28 20:10 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Riku Voipio @ 2009-01-28 18:47 UTC (permalink / raw)
To: qemu-devel
testcase:
qemu-arm|grep cpu
Without fflush() getting output from piped qemu is a bit random.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
bsd-user/main.c | 1 +
darwin-user/main.c | 1 +
linux-user/main.c | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 636f1dc..f3cb3b1 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -351,6 +351,7 @@ static void usage(void)
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
+ fflush(stdout);
_exit(1);
}
diff --git a/darwin-user/main.c b/darwin-user/main.c
index 3edad73..44e8f7c 100644
--- a/darwin-user/main.c
+++ b/darwin-user/main.c
@@ -758,6 +758,7 @@ void usage(void)
interp_prefix,
stack_size,
DEBUG_LOGFILE);
+ fflush(stdout);
_exit(1);
}
diff --git a/linux-user/main.c b/linux-user/main.c
index 3418ca6..9b807e5 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2216,6 +2216,7 @@ static void usage(void)
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
+ fflush(stdout);
_exit(1);
}
--
1.5.6.5
--
"rm -rf" only sounds scary if you don't have backups
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] flush stdout after printing usage()
2009-01-28 18:47 [Qemu-devel] [PATCH] flush stdout after printing usage() Riku Voipio
@ 2009-01-28 20:10 ` Anthony Liguori
2009-01-28 21:06 ` Riku Voipio
0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2009-01-28 20:10 UTC (permalink / raw)
To: qemu-devel
Riku Voipio wrote:
> testcase:
>
> qemu-arm|grep cpu
>
> Without fflush() getting output from piped qemu is a bit random.
>
It should get flushed upon exit(). Perhaps the problem is that we're
using _exit() instead of exit()?
Regards,
Anthony Liguori
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> ---
> bsd-user/main.c | 1 +
> darwin-user/main.c | 1 +
> linux-user/main.c | 1 +
> 3 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index 636f1dc..f3cb3b1 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -351,6 +351,7 @@ static void usage(void)
> interp_prefix,
> x86_stack_size,
> DEBUG_LOGFILE);
> + fflush(stdout);
> _exit(1);
> }
>
> diff --git a/darwin-user/main.c b/darwin-user/main.c
> index 3edad73..44e8f7c 100644
> --- a/darwin-user/main.c
> +++ b/darwin-user/main.c
> @@ -758,6 +758,7 @@ void usage(void)
> interp_prefix,
> stack_size,
> DEBUG_LOGFILE);
> + fflush(stdout);
> _exit(1);
> }
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 3418ca6..9b807e5 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -2216,6 +2216,7 @@ static void usage(void)
> interp_prefix,
> x86_stack_size,
> DEBUG_LOGFILE);
> + fflush(stdout);
> _exit(1);
> }
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] flush stdout after printing usage()
2009-01-28 20:10 ` Anthony Liguori
@ 2009-01-28 21:06 ` Riku Voipio
2009-01-28 21:51 ` Lionel Landwerlin
0 siblings, 1 reply; 6+ messages in thread
From: Riku Voipio @ 2009-01-28 21:06 UTC (permalink / raw)
To: qemu-devel
On Wed, Jan 28, 2009 at 02:10:42PM -0600, Anthony Liguori wrote:
> Riku Voipio wrote:
> >testcase:
> >
> >qemu-arm|grep cpu
> >
> >Without fflush() getting output from piped qemu is a bit random.
> It should get flushed upon exit(). Perhaps the problem is that we're
> using _exit() instead of exit()?
Well yes in my testing, replacing _exit() with exit() fixes it too.
I just presumed _exit() was there for a purpose.
> Regards,
>
> Anthony Liguori
>
> >Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> >---
> > bsd-user/main.c | 1 +
> > darwin-user/main.c | 1 +
> > linux-user/main.c | 1 +
> > 3 files changed, 3 insertions(+), 0 deletions(-)
> >
> >diff --git a/bsd-user/main.c b/bsd-user/main.c
> >index 636f1dc..f3cb3b1 100644
> >--- a/bsd-user/main.c
> >+++ b/bsd-user/main.c
> >@@ -351,6 +351,7 @@ static void usage(void)
> > interp_prefix,
> > x86_stack_size,
> > DEBUG_LOGFILE);
> >+ fflush(stdout);
> > _exit(1);
> > }
> >
> >diff --git a/darwin-user/main.c b/darwin-user/main.c
> >index 3edad73..44e8f7c 100644
> >--- a/darwin-user/main.c
> >+++ b/darwin-user/main.c
> >@@ -758,6 +758,7 @@ void usage(void)
> > interp_prefix,
> > stack_size,
> > DEBUG_LOGFILE);
> >+ fflush(stdout);
> > _exit(1);
> > }
> >
> >diff --git a/linux-user/main.c b/linux-user/main.c
> >index 3418ca6..9b807e5 100644
> >--- a/linux-user/main.c
> >+++ b/linux-user/main.c
> >@@ -2216,6 +2216,7 @@ static void usage(void)
> > interp_prefix,
> > x86_stack_size,
> > DEBUG_LOGFILE);
> >+ fflush(stdout);
> > _exit(1);
> > }
> >
> >
>
>
--
"rm -rf" only sounds scary if you don't have backups
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] flush stdout after printing usage()
2009-01-28 21:06 ` Riku Voipio
@ 2009-01-28 21:51 ` Lionel Landwerlin
2009-01-28 22:00 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Lionel Landwerlin @ 2009-01-28 21:51 UTC (permalink / raw)
To: qemu-devel
Le mercredi 28 janvier 2009 à 23:06 +0200, Riku Voipio a écrit :
> On Wed, Jan 28, 2009 at 02:10:42PM -0600, Anthony Liguori wrote:
> > Riku Voipio wrote:
> > >testcase:
> > >
> > >qemu-arm|grep cpu
> > >
> > >Without fflush() getting output from piped qemu is a bit random.
>
> > It should get flushed upon exit(). Perhaps the problem is that we're
> > using _exit() instead of exit()?
>
_exit does not trigger callbacks registred with at_exit.
from the man page :
The function _exit() is like exit(3), but does not call any functions
registered with atexit(3) or on_exit(3). Whether it flushes standard
I/O buffers and removes temporary files created with tmpfile(3) is
implementation-dependent. On the other hand, _exit() does close open
file descriptors, and this may cause an unknown delay, waiting for
pending output to finish. If the delay is undesired, it may be useful
to call functions like tcflush(3) before calling _exit(). Whether any
pending I/O is canceled, and which pending I/O may be canceled upon
_exit(), is implementation-dependent.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] flush stdout after printing usage()
2009-01-28 21:51 ` Lionel Landwerlin
@ 2009-01-28 22:00 ` Anthony Liguori
2009-02-06 14:33 ` Riku Voipio
0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2009-01-28 22:00 UTC (permalink / raw)
To: qemu-devel
Lionel Landwerlin wrote:
> Le mercredi 28 janvier 2009 à 23:06 +0200, Riku Voipio a écrit :
>
>> On Wed, Jan 28, 2009 at 02:10:42PM -0600, Anthony Liguori wrote:
>>
>>> Riku Voipio wrote:
>>>
>>>> testcase:
>>>>
>>>> qemu-arm|grep cpu
>>>>
>>>> Without fflush() getting output from piped qemu is a bit random.
>>>>
>>> It should get flushed upon exit(). Perhaps the problem is that we're
>>> using _exit() instead of exit()?
>>>
>
> _exit does not trigger callbacks registred with at_exit.
>
Yes. The question is why is it being used? What at_exit handler are we
trying to avoid.
Regards,
Anthony Liguori
> from the man page :
>
> The function _exit() is like exit(3), but does not call any functions
> registered with atexit(3) or on_exit(3). Whether it flushes standard
> I/O buffers and removes temporary files created with tmpfile(3) is
> implementation-dependent. On the other hand, _exit() does close open
> file descriptors, and this may cause an unknown delay, waiting for
> pending output to finish. If the delay is undesired, it may be useful
> to call functions like tcflush(3) before calling _exit(). Whether any
> pending I/O is canceled, and which pending I/O may be canceled upon
> _exit(), is implementation-dependent.
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] flush stdout after printing usage()
2009-01-28 22:00 ` Anthony Liguori
@ 2009-02-06 14:33 ` Riku Voipio
0 siblings, 0 replies; 6+ messages in thread
From: Riku Voipio @ 2009-02-06 14:33 UTC (permalink / raw)
To: qemu-devel
On Wed, Jan 28, 2009 at 04:00:09PM -0600, Anthony Liguori wrote:
> Lionel Landwerlin wrote:
>>> On Wed, Jan 28, 2009 at 02:10:42PM -0600, Anthony Liguori wrote:
>>>> Riku Voipio wrote:
>>>>> Without fflush() getting output from piped qemu is a bit random.
>>>>>
>>>> It should get flushed upon exit(). Perhaps the problem is that
>>>> we're using _exit() instead of exit()?
>>>>
>> _exit does not trigger callbacks registred with at_exit.
> Yes. The question is why is it being used? What at_exit handler are we
> trying to avoid.
Historic reasons? Just to "be safe" since system qemu uses atexit handlers?
I don't see any atexit handlers registered for linux-user (or bsd-user)
targets for current svn qemu. Definetly none registered at command line parsing
stage.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-06 14:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 18:47 [Qemu-devel] [PATCH] flush stdout after printing usage() Riku Voipio
2009-01-28 20:10 ` Anthony Liguori
2009-01-28 21:06 ` Riku Voipio
2009-01-28 21:51 ` Lionel Landwerlin
2009-01-28 22:00 ` Anthony Liguori
2009-02-06 14:33 ` Riku Voipio
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).