[alsa-devel] [PATCH 1/2] hda-emu: Flush output before prompt

David Henningsson david.henningsson at canonical.com
Wed Aug 8 11:54:29 CEST 2012


When stdout is redirected, there is a risk not all stdout is sent
before the prompt is sent on stderr. Thanks to Jeremy Kerr for
help with this issue.
---
 hda-ctlsh.c       |    1 +
 hda-log.c         |    5 +++++
 include/hda-log.h |    1 +
 3 files changed, 7 insertions(+)

diff --git a/hda-ctlsh.c b/hda-ctlsh.c
index 4c21341..d84cc71 100644
--- a/hda-ctlsh.c
+++ b/hda-ctlsh.c
@@ -851,6 +851,7 @@ int cmd_loop(FILE *fp)
 	init_completion();
 
 	for (;;) {
+		hda_log_flush();
 		line = readline("> ");
 		if (!line)
 			break;
diff --git a/hda-log.c b/hda-log.c
index 65f3044..67ee8e2 100644
--- a/hda-log.c
+++ b/hda-log.c
@@ -179,6 +179,11 @@ int hda_log_level_set(int level)
 	return saved;
 }
 
+void hda_log_flush()
+{
+	fflush(logfp);
+}
+
 FILE *hda_get_logfp(void)
 {
 	return logfp;
diff --git a/include/hda-log.h b/include/hda-log.h
index 2e2137b..8b0d392 100644
--- a/include/hda-log.h
+++ b/include/hda-log.h
@@ -18,6 +18,7 @@ int hda_log_init(const char *file, unsigned int flags);
 void hda_log(int level, const char *fmt, ...);
 void hda_log_printk(const char *fmt, ...);
 void hda_log_echo(int level, const char *fmt, ...);
+void hda_log_flush(void);
 
 extern int hda_log_trap_on_error;
 
-- 
1.7.9.5



More information about the Alsa-devel mailing list