From 2d9579da2144b2a8d67ea1d05fde96ec9d365944 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Jul 2016 12:47:21 +0300 Subject: Adapt to fdstream extension --- build2/utility.txx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'build2/utility.txx') diff --git a/build2/utility.txx b/build2/utility.txx index bf9d9ab..a00f3fb 100644 --- a/build2/utility.txx +++ b/build2/utility.txx @@ -13,24 +13,30 @@ namespace build2 sha256* checksum) { process pr (start_run (args, err)); - ifdstream is (pr.in_ofd); T r; - string l; // Last line of output. - while (is.peek () != ifdstream::traits_type::eof () && // Keep last line. - getline (is, l)) + + try { - trim (l); + ifdstream is (pr.in_ofd); - if (checksum != nullptr) - checksum->append (l); + while (is.peek () != ifdstream::traits_type::eof () && // Keep last line. + getline (is, l)) + { + trim (l); - if (r.empty ()) - r = f (l); - } + if (checksum != nullptr) + checksum->append (l); - is.close (); // Don't block. + if (r.empty ()) + r = f (l); + } + } + catch (const ifdstream::failure&) + { + // Presumably the child process failed. Let finish_run() deal with that. + } if (!(finish_run (args, err, pr, l) || ignore_exit)) r = T (); -- cgit v1.1