diff --git a/src/srun/io.c b/src/srun/io.c index 880ded5d0f0e8607ac54a5a946e8ab722aa4e770..1befb1a38f80799c383fd9b63226991e6d244f69 100644 --- a/src/srun/io.c +++ b/src/srun/io.c @@ -674,12 +674,25 @@ _do_task_output(int *fd, FILE *out, cbuf_t buf, int tasknum) int len = 0; int dropped = 0; + again: if ((len = cbuf_write_from_fd(buf, *fd, -1, &dropped)) < 0) { + + /* + * If output buffer is full, flush all output to + * output stream + */ + if (errno == ENOSPC) { + cbuf_read_to_fd(buf, fileno(out), -1); + goto again; + } + if (errno == EAGAIN) return 0; + error("Error task %d IO: %m", tasknum); _close_stream(fd, out, tasknum); return len; + } else if (len == 0) { _close_stream(fd, out, tasknum); return len;