aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/system.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/util/system.cc')
-rw-r--r--paludis/util/system.cc16
1 files changed, 4 insertions, 12 deletions
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index ca9ff8e..3898955 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -1075,18 +1075,10 @@ paludis::become_command(const Command & cmd)
/* Feed in any input things */
if (cmd.input_stream())
{
- while (true)
- {
- char c;
- if (cmd.input_stream()->get(c).good())
- {
- int w(write(input_stream->write_fd(), &c, 1));
- if (w != 1)
- throw RunCommandError("write failed: " + stringify(strerror(errno)));
- }
- else
- break;
- }
+ SafeOFStream output_stream(input_stream->write_fd());
+ std::copy((std::istreambuf_iterator<char>(*cmd.input_stream())),
+ std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(output_stream));
if (0 != close(input_stream->write_fd()))
throw RunCommandError("close failed: " + stringify(strerror(errno)));