initfs: Use stty to drain output before reboot

To see all the messages during shutdown call stty cooked.

A side effect of setting any mode is it will call ioctl(TIOC_DRAIN)
to drain the buffers first without regard to any change in the mode.

Shutdown and flash update now show the final ouptut and "Rebooting"
message before the reboot system call.

Before:
+ set +x
Remaining mounts:
tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
proc /proc proc rw,relatime 0 0
sys /s

U-Boot 2013.07 (Feb 23 2016 - 10:21:23)

After:
+ set +x
Remaining mounts:
tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
proc /proc proc rw,relatime 0 0
sys /sys sysfs rw,relatime 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
reboot: Restarting system

U-Boot 2013.07 (Feb 23 2016 - 10:21:23)

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
diff --git a/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index 3eff1ea..fc359c5 100644
--- a/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -47,6 +47,8 @@
 
 test "umount_proc" && umount /proc && rmdir /proc
 
+# ioctl(TIOC_DRAIN) to drain tty messages to console
+test -t 1 && stty cooked 0<&1
 
 # Execute the command systemd told us to ...
 if test -d /oldroot  && test "$1"