From c6522a029183a65a928be690ce37e0be934a4f48 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 2 Sep 2019 07:46:04 +0000 Subject: [PATCH] changed mod-sys.c to check O_CLOEXEC and O_NONBLOCK before using them --- qse/lib/awk/mod-sys.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qse/lib/awk/mod-sys.c b/qse/lib/awk/mod-sys.c index c2cfb92e..60b53d23 100644 --- a/qse/lib/awk/mod-sys.c +++ b/qse/lib/awk/mod-sys.c @@ -661,7 +661,7 @@ static int fnc_dup (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) #if defined(HAVE_DUP3) fd = dup3(sys_node->ctx.u.fd, sys_node2->ctx.u.fd, oflags); #else - fd = dup2(sys_node->ctx.u.fd); + fd = dup2(sys_node->ctx.u.fd, sys_node2->ctx.u.fd); #endif if (fd >= 0) { @@ -671,8 +671,12 @@ static int fnc_dup (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) if (oflags) { int nflags = 0; + #if defined(O_CLOEXEC) && defined(FD_CLOEXEC) if (oflags & O_CLOEXEC) nflags |= FD_CLOEXEC; + #endif + #if defined(O_NONBLOCK) && defined(FD_NONBLOCK) /*if (oflags & O_NONBLOCK) nflags |= FD_NONBLOCK; dup3() doesn't seem to support NONBLOCK. */ + #endif if (nflags) fcntl (fd, F_SETFD, nflags); }