Skip to content

Commit

Permalink
Protect boost process output read loop from deadlock
Browse files Browse the repository at this point in the history
As per the boost::process tutorials
  • Loading branch information
gjanssens authored and jralls committed Oct 2, 2022
1 parent f658ff4 commit d79306f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libgnucash/quotes/gnc-quotes.cpp
Expand Up @@ -53,12 +53,13 @@ GncQuotes::check (void)
bp::child process (perl_executable, "-w", fq_check, bp::std_out > out_stream, bp::std_err > err_stream);

std::string stream_line;
while (getline (out_stream, stream_line))
while (process.running() && getline (out_stream, stream_line))
if (m_version.empty())
std::swap (m_version, stream_line);
else
m_sources.push_back (std::move(stream_line));
while (getline (err_stream, stream_line))

while (process.running() && getline (err_stream, stream_line))
m_error_msg.append(stream_line + "\n");

process.wait();
Expand Down

0 comments on commit d79306f

Please sign in to comment.