From 15507d112650477ad64a5c9b19b4e515124affec Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 18 Nov 2020 17:32:25 +0300 Subject: Fix set buildscript builtin crash on Windows --- libbuild2/script/run.cxx | 20 +++++++++++++++++++- tests/test/script/runner/set.testscript | 9 ++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx index 703cd11..ca4a935 100644 --- a/libbuild2/script/run.cxx +++ b/libbuild2/script/run.cxx @@ -844,6 +844,11 @@ namespace build2 set_builtin (environment& env, const strings& args, auto_fd in, +#ifndef _WIN32 + bool, +#else + bool pipe, +#endif const optional& dl, const command& deadline_cmd, const location& ll) @@ -889,7 +894,19 @@ namespace build2 // variable value will be incomplete, but we leave it to the caller // to handle that. // + // Note that on Windows we can only turn pipe file descriptors into + // the non-blocking mode. Thus, we have no choice but to read from + // descriptors of other types synchronously there. That implies that + // we can potentially block indefinitely reading a file and missing + // the deadline on Windows. Note though, that the user can always + // rewrite `set foo <<= 2) print_process (process_args ()); - set_builtin (env, c.arguments, move (ifd), + set_builtin (env, c.arguments, + move (ifd), !first, dl, dl_cmd != nullptr ? *dl_cmd : c, ll); diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript index 41709e4..777eccf 100644 --- a/tests/test/script/runner/set.testscript +++ b/tests/test/script/runner/set.testscript @@ -276,7 +276,14 @@ : $c <foo 2>| + echo "$bar" >'foo' + EOI + + : non-pipe + : + $c <'foo' EOI : set-reached -- cgit v1.1