summaryrefslogtreecommitdiff
path: root/src/stream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream.cc')
-rw-r--r--src/stream.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/stream.cc b/src/stream.cc
index 272d4f1c..5d4cf5e0 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -63,6 +63,7 @@ namespace {
*/
int do_fork(std::ostream ** os, const path& pager_path)
{
+#ifndef WIN32
int pfd[2];
int status = pipe(pfd);
@@ -73,11 +74,11 @@ namespace {
if (status < 0) {
throw std::logic_error(_("Failed to fork child process"));
}
- else if (status == 0) { // child
+ else if (status == 0) { // child
// Duplicate pipe's reading end into stdin
status = dup2(pfd[0], STDIN_FILENO);
if (status == -1)
- perror("dup2");
+ perror("dup2");
// Close unuseful file descriptors: the pipe's writing and reading
// ends (the latter is not needed anymore, after the duplication).
@@ -98,17 +99,24 @@ namespace {
perror((std::string("execlp: ") + pager_path.string()).c_str());
exit(1);
}
- else { // parent
+ else { // parent
close(pfd[0]);
typedef iostreams::stream<iostreams::file_descriptor_sink> fdstream;
+#if BOOST_VERSION >= 104400
+ *os = new fdstream(pfd[1], iostreams::never_close_handle);
+#else // BOOST_VERSION >= 104400
*os = new fdstream(pfd[1]);
+#endif // BOOST_VERSION >= 104400
}
return pfd[1];
+#else
+ return 0;
+#endif
}
}
void output_stream_t::initialize(const optional<path>& output_file,
- const optional<path>& pager_path)
+ const optional<path>& pager_path)
{
if (output_file && *output_file != "-")
os = new ofstream(*output_file);
@@ -120,6 +128,7 @@ void output_stream_t::initialize(const optional<path>& output_file,
void output_stream_t::close()
{
+#ifndef WIN32
if (os != &std::cout) {
checked_delete(os);
os = &std::cout;
@@ -134,6 +143,7 @@ void output_stream_t::close()
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0)
throw std::logic_error(_("Error in the pager"));
}
+#endif
}
} // namespace ledger