From: Willy Tarreau Date: Tue, 27 Aug 2019 08:34:32 +0000 (+0200) Subject: MINOR: sink: set the fd-type sinks to non-blocking X-Git-Tag: v2.1-dev2~170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=799e9ed62b4384a16340d301ee6ab490a082318a;p=thirdparty%2Fhaproxy.git MINOR: sink: set the fd-type sinks to non-blocking Just like we used to do for the logs, we must disable blocking on FD output except if it's a terminal. --- diff --git a/src/sink.c b/src/sink.c index f3e18ccb20..214b272ef4 100644 --- a/src/sink.c +++ b/src/sink.c @@ -19,6 +19,8 @@ */ #include +#include +#include #include #include #include @@ -89,6 +91,11 @@ struct sink *sink_new_fd(const char *name, const char *desc, enum sink_fmt fmt, goto end; } + /* FD not yet initialized to non-blocking mode. + * DON'T DO IT ON A TERMINAL! + */ + if (!isatty(fd)) + fcntl(fd, F_SETFL, O_NONBLOCK); sink->type = SINK_TYPE_FD; sink->ctx.fd = fd; end: