From ea119151ccc51bd11d66821a2cf194d2254471c0 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 11 Mar 2024 17:15:42 +0000 Subject: [PATCH] watch: flush the buffer each time around the loop. Also fix -b to use \a (alarm) rather than \b (backspace). --- toys/other/watch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/other/watch.c b/toys/other/watch.c index 14048d85..995aae15 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -40,8 +40,7 @@ static void watch_child(int sig) status = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+127; if (status) { - // TODO should this be beep()? - if (FLAG(b)) putchar('\b'); + if (FLAG(b)) putchar('\a'); if (FLAG(e)) { printf("Exit status %d\r\n", status); tty_reset(); @@ -89,6 +88,7 @@ void watch_main(void) xsignal_flags(SIGCHLD, watch_child, SA_RESTART|SA_NOCLDSTOP); for (;;) { + fflush(NULL); // Time for a new period? if ((now = millitime())>=then) { -- 2.39.2