Fixed the way the pager process was being handled.
This commit is contained in:
parent
9d267fa133
commit
559a76ac2b
3 changed files with 21 additions and 9 deletions
|
|
@ -139,6 +139,9 @@ int main(int argc, char * argv[], char * envp[])
|
||||||
status = _status;
|
status = _status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close the output stream, waiting on the pager process if need be
|
||||||
|
session->report->output_stream.close();
|
||||||
|
|
||||||
// If memory verification is being performed (which can be very slow), clean
|
// If memory verification is being performed (which can be very slow), clean
|
||||||
// up everything by closing the session and deleting the session object, and
|
// up everything by closing the session and deleting the session object, and
|
||||||
// then shutting down the memory tracing subsystem. Otherwise, let it all
|
// then shutting down the memory tracing subsystem. Otherwise, let it all
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace {
|
||||||
(char *)0);
|
(char *)0);
|
||||||
|
|
||||||
// We should never, ever reach here
|
// We should never, ever reach here
|
||||||
perror("execl");
|
perror((std::string("execl: ") + pager_path.string()).c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
else { // parent
|
else { // parent
|
||||||
|
|
@ -114,21 +114,22 @@ void output_stream_t::initialize(const optional<path>& output_file,
|
||||||
{
|
{
|
||||||
if (output_file)
|
if (output_file)
|
||||||
os = new ofstream(*output_file);
|
os = new ofstream(*output_file);
|
||||||
else if (pager_path && exists(*pager_path))
|
else if (pager_path)
|
||||||
pipe_to_pager_fd = do_fork(&os, *pager_path);
|
pipe_to_pager_fd = do_fork(&os, *pager_path);
|
||||||
else
|
else
|
||||||
os = &std::cout;
|
os = &std::cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
output_stream_t::~output_stream_t()
|
void output_stream_t::close()
|
||||||
{
|
{
|
||||||
TRACE_DTOR(output_stream_t);
|
if (os != &std::cout) {
|
||||||
|
|
||||||
if (os && os != &std::cout)
|
|
||||||
checked_delete(os);
|
checked_delete(os);
|
||||||
|
os = &std::cout;
|
||||||
|
}
|
||||||
|
|
||||||
if (pipe_to_pager_fd != -1) {
|
if (pipe_to_pager_fd != -1) {
|
||||||
close(pipe_to_pager_fd);
|
::close(pipe_to_pager_fd);
|
||||||
|
pipe_to_pager_fd = -1;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
wait(&status);
|
wait(&status);
|
||||||
|
|
|
||||||
12
src/stream.h
12
src/stream.h
|
|
@ -76,7 +76,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Construct a new output_stream_t.
|
* Construct a new output_stream_t.
|
||||||
*/
|
*/
|
||||||
output_stream_t() : pipe_to_pager_fd(-1), os(NULL) {
|
output_stream_t() : pipe_to_pager_fd(-1), os(&std::cout) {
|
||||||
TRACE_CTOR(output_stream_t, "");
|
TRACE_CTOR(output_stream_t, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,10 @@ public:
|
||||||
* allocated ostream, if necessary. It also closes output file
|
* allocated ostream, if necessary. It also closes output file
|
||||||
* descriptor, if necessary.
|
* descriptor, if necessary.
|
||||||
*/
|
*/
|
||||||
~output_stream_t();
|
~output_stream_t() {
|
||||||
|
TRACE_DTOR(output_stream_t);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the output stream object.
|
* Initialize the output stream object.
|
||||||
|
|
@ -113,6 +116,11 @@ public:
|
||||||
void flush() {
|
void flush() {
|
||||||
os->flush();
|
os->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the output stream, waiting on the pager process if necessary.
|
||||||
|
*/
|
||||||
|
void close();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue