From 03518e5bab4cf6fab4d9c517e349e375aec89faf Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 25 Sep 2012 22:46:12 +0900 Subject: [PATCH] don't write zero bytes on flush (more efficient and avoids sigpipe) --- sexp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sexp.c b/sexp.c index f62adf22..239cc00b 100644 --- a/sexp.c +++ b/sexp.c @@ -1466,7 +1466,8 @@ int sexp_buffered_flush (sexp ctx, sexp p, int forcep) { if (off > 0) fwrite(sexp_port_buf(p), 1, off, sexp_port_stream(p)); res = fflush(sexp_port_stream(p)); } else if (sexp_filenop(sexp_port_fd(p))) { - res = write(sexp_fileno_fd(sexp_port_fd(p)), sexp_port_buf(p), off); + if (off > 0) + res = write(sexp_fileno_fd(sexp_port_fd(p)), sexp_port_buf(p), off); if (res < off) { if (res > 0) { memmove(sexp_port_buf(p), sexp_port_buf(p) + res, off - res);