diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-16 14:32:23 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-16 14:36:33 +0300 |
commit | 86d62d746d8e2586e1b3a2995f7119d0562145b8 (patch) | |
tree | 592ee9b7e7ea2e2dc4dfd2320f895a3097168e43 /t | |
parent | b40125990e923f743fa4a1b53c7af05feda422cc (diff) | |
download | runcap-86d62d746d8e2586e1b3a2995f7119d0562145b8.tar.gz runcap-86d62d746d8e2586e1b3a2995f7119d0562145b8.tar.bz2 |
Explicitly indicate EOF when sc_linemon is initialized.
* runcap.3: Document changes.
* runcap.c (stream_capture_get): Indicate EOF explicitly by
calling sc_linemon function with 0 as line length.
* t/rt.c (linemon): Update to handle this case.
Diffstat (limited to 't')
-rw-r--r-- | t/rt.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -92,14 +92,17 @@ static void linemon(const char *ptr, size_t len, void *data) { struct linemon_closure *clos = data; - - if (!clos->cont) { - printf("%s:", clos->prefix); - if (!(len == 1 && ptr[0] == '\n')) - putchar(' '); - } - fwrite(ptr, len, 1, stdout); - clos->cont = ptr[len-1] != '\n'; + + if (len) { + if (!clos->cont) { + printf("%s:", clos->prefix); + if (!(len == 1 && ptr[0] == '\n')) + putchar(' '); + } + fwrite(ptr, len, 1, stdout); + } else + fflush(stdout); + clos->cont = !(len == 0 || ptr[len-1] == '\n'); } static void |