aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-11-24 14:15:37 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-11-24 19:50:13 +0300
commit0ea11771d82f47bcef891544b76c81f94838a30d (patch)
treea0f8887cc311d55e16274a4c69d41912d798bb01 /libbuild2
parentb90393fdce6223405b8c144e3a9617a5e82e6e78 (diff)
Fix skipping potential input for exit, etc script pseudo-builtins
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/script/run.cxx29
1 files changed, 22 insertions, 7 deletions
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx
index 7b08898..f486138 100644
--- a/libbuild2/script/run.cxx
+++ b/libbuild2/script/run.cxx
@@ -1738,14 +1738,29 @@ namespace build2
// content), to make sure that the command doesn't print any unwanted
// diagnostics about IO operation failure.
//
- // Note though, that doing so would be a bad idea if the deadline is
- // specified, since we can block on read and miss the deadline.
- //
- if (!dl)
- {
- // Note that dtor will ignore any errors (which is what we want).
+ if (ifd != nullfd)
+ {
+ // Note that we can't use ifdstream dtor in the skip mode here since
+ // it turns the stream into the blocking mode and we won't be able
+ // to read out the potentially buffered stderr for the
+ // pipeline. Using read() is also not ideal since it performs
+ // parsing and allocations needlessly. This, however, is probably ok
+ // for such an uncommon case.
//
- ifdstream (move (ifd), fdstream_mode::skip);
+ //ifdstream (move (ifd), fdstream_mode::skip);
+
+ // Let's try to minimize the allocation size splitting the input
+ // data at whitespaces.
+ //
+ read (move (ifd),
+ true /* whitespace */,
+ false /* newline */,
+ false /* exact */,
+ [] (string&&) {}, // Just drop the string.
+ prev_cmd,
+ dl,
+ ll,
+ program.c_str ());
}
if (!first || !last)