logos: Don't print a blank line when process exits.
Before:
GSAFSJ1412D0117# echo testing | logos testfacility
GSAFSJ1412D0117# dmesg | grep testfacility
[ 2194.480329] testfacility: testing
[ 2194.480356] testfacility:
GSAFSJ1412D0117#
GSAFSJ1412D0117# echo -n | logos testfacility
GSAFSJ1412D0117# dmesg | grep testfacility
[12366.425968] testfacility:
GSAFSJ1412D0117#
After:
GSAFSJ1412D0117# echo testing | /tmp/logos testfacility
GSAFSJ1412D0117# dmesg | grep testfacility
[ 2211.275520] testfacility: testing
GSAFSJ1412D0117#
GSAFSJ1412D0117# echo -n | /tmp/logos testfacility
GSAFSJ1412D0117# dmesg | grep testfacility
GSAFSJ1412D0117#
Change-Id: Iae5aa6c141f2597454931f07b167a759e060f626
diff --git a/cmds/logos.c b/cmds/logos.c
index 6c186a5..93577ce 100644
--- a/cmds/logos.c
+++ b/cmds/logos.c
@@ -642,7 +642,11 @@
}
got = read(0, buf + used, sizeof(buf) - used);
if (got == 0) {
- flush(header, headerlen, buf, used);
+ if (used > 0) {
+ /* Only output if there is text in the buffer, avoid
+ * printing a blank line when a process exits. */
+ flush(header, headerlen, buf, used);
+ }
goto done;
} else if (got < 0) {
if (errno != EINTR && errno != EAGAIN) {