diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-23 08:57:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-23 08:57:45 +0200 |
commit | c6b1d1dd870b3370d0a09fb4600e3a6b03326f35 (patch) | |
tree | f400b0d4a67bd1e067b545372e7742c5665f5caf /libbuild2/diagnostics.cxx | |
parent | f19959de304afaff2b3d539c9bef1f493ede5fbd (diff) |
Rework diag_buffer interface to facilitate correct destruction order
Diffstat (limited to 'libbuild2/diagnostics.cxx')
-rw-r--r-- | libbuild2/diagnostics.cxx | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/libbuild2/diagnostics.cxx b/libbuild2/diagnostics.cxx index 3246cae..bc74db3 100644 --- a/libbuild2/diagnostics.cxx +++ b/libbuild2/diagnostics.cxx @@ -498,41 +498,35 @@ namespace build2 // diag_buffer // - process::pipe diag_buffer:: - open (const char* args0, bool force, fdstream_mode m) + + int diag_buffer:: + pipe (context& ctx, bool force) + { + return (ctx.sched.serial () || ctx.no_diag_buffer) && !force ? 2 : -1; + } + + void diag_buffer:: + open (const char* args0, auto_fd&& fd, fdstream_mode m) { assert (state_ == state::closed && args0 != nullptr); serial = ctx_.sched.serial (); nobuf = !serial && ctx_.no_diag_buffer; - process::pipe r; - if (!(serial || nobuf) || force) + if (fd != nullfd) { try { - fdpipe p (fdopen_pipe ()); - - // Note that we must return non-owning fd to our end of the pipe (see - // the process class for details). - // - r = process::pipe (p.in.get (), move (p.out)); - - m |= fdstream_mode::text; - - is.open (move (p.in), m); + is.open (move (fd), m | fdstream_mode::text); } catch (const io_error& e) { fail << "unable to read from " << args0 << " stderr: " << e; } } - else - r = process::pipe (-1, 2); this->args0 = args0; state_ = state::opened; - return r; } void diag_buffer:: |