From: Job Snijders Subject: watch(1): interleave stdout+stderr To: tech@openbsd.org Date: Mon, 23 Jun 2025 23:09:13 +0000 We should interleave stdout and stderr emitted by the child. This makes "watch traceroute kiera.meerval.net" easier on the eyes, and makes for example "watch make" output readable in case messages are printed to stderr. Other 'watch' implementations also interleave these two streams. OK? Index: watch.c =================================================================== RCS file: /cvs/src/usr.bin/watch/watch.c,v diff -u -p -r1.29 watch.c --- watch.c 22 Jun 2025 21:57:51 -0000 1.29 +++ watch.c 23 Jun 2025 23:02:05 -0000 @@ -412,10 +412,9 @@ start_child() err(1, "vfork"); if (child->pid == 0) { close(fds[0]); - if (fds[1] != STDOUT_FILENO) { - dup2(fds[1], STDOUT_FILENO); - close(fds[1]); - } + dup2(fds[1], STDOUT_FILENO); + dup2(fds[1], STDERR_FILENO); + close(fds[1]); if (xflag) execvp(cmdv[0], cmdv); else @@ -541,11 +540,6 @@ kbd_command(int ch) case ' ': /* Execute the command again. */ return (RSLT_UPDATE); - /* - * XXX: redrawing with Control-l often is needed when the command - * emitted things to stderr. The program ought to interleave stdout - * and stderr. - */ case ctrl('l'): clear(); break;