Output of run script not getting flushed
Andreas Sommer <[email protected]> Fri, 22 Mar 2019 11:43:58 +0100
| Newsgroups | gmane.comp.djb.syslog |
|---|---|
| Message-ID | <[email protected]> |
Hi all, I'm experiencing a problem of application output not showing up until it has finished (or probably until the stdout buffer is full). run: > #!/bin/sh > exec 2>&1 > exec python -c "while True: import time; print time.time(); time.sleep(0.2)" log/run: > #!/bin/sh > exec setuidgid nobody multilog t s5000000 ./main Then, `tail -F log/main/current` should constantly print around 5 lines per second, but nothing to be seen. In my Python-based production application, we can see output only once it finishes. These are the things I tried: - `python -u` (unbuffered) resolves the issue but feels like a hack, since usually output should be line-buffered, right? And we have daemontools working for many other use cases where things work as usual, i.e. output flushed line-by-line. - C program doing the same while loop has the same issue - `exec cat -u >>./main/current` as log program shows the same issue - `python -c ... | cat -u` (without `exec`) as run program shows the same issue - OS and package versions where I observe the problem: FreeBSD 9.1, FreeBSD 10.3, Raspbian GNU/Linux 9.6 (stretch), all using daemontools 0.76 Is this something stupidly simple, maybe? Cheers, Andreas