From c2c977a4f24a5b43429395880e40d944e711251b Mon Sep 17 00:00:00 2001 From: vdhoeven Date: Tue, 1 Dec 2009 09:10:03 +0000 Subject: [PATCH] Fix non flushed cerr bug git-svn-id: svn://svn.savannah.gnu.org/texmacs/trunk@2845 64cb5145-927a-446d-8aed-2fb7b4773692 --- src/src/System/Link/pipe_link.cpp | 44 +++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/src/System/Link/pipe_link.cpp b/src/src/System/Link/pipe_link.cpp index 76d6897a..c42a004e 100644 --- a/src/src/System/Link/pipe_link.cpp +++ b/src/src/System/Link/pipe_link.cpp @@ -55,29 +55,33 @@ static void pipe_callback (void *obj, void *info) { if (!is_nil (con->feed_cmd)) con->feed_cmd->apply (); // call the data processor } #else - fd_set rfds; - FD_ZERO (&rfds); - int max_fd= max (con->err, con->out)+1; - FD_SET (con->out, &rfds); - FD_SET (con->err, &rfds); + bool busy= true; + bool news= false; + while (busy) { + fd_set rfds; + FD_ZERO (&rfds); + int max_fd= max (con->err, con->out) + 1; + FD_SET (con->out, &rfds); + FD_SET (con->err, &rfds); - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - select (max_fd, &rfds, NULL, NULL, &tv); + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + select (max_fd, &rfds, NULL, NULL, &tv); - bool any_update = false; - if (con->alive && FD_ISSET (con->out, &rfds)) { - //cout << "pipe_callback OUT" << LF; - con->feed (LINK_OUT); - any_update = true; - } - if (con->alive && FD_ISSET (con->err, &rfds)) { - //cout << "pipe_callback ERR" << LF; - con->feed (LINK_ERR); - any_update = true; + busy= false; + if (con->alive && FD_ISSET (con->out, &rfds)) { + //cout << "pipe_callback OUT" << LF; + con->feed (LINK_OUT); + busy= news= true; + } + if (con->alive && FD_ISSET (con->err, &rfds)) { + //cout << "pipe_callback ERR" << LF; + con->feed (LINK_ERR); + busy= news= true; + } } - if (!is_nil (con->feed_cmd) && any_update) { + if (!is_nil (con->feed_cmd) && news) { //cout << "pipe_callback APPLY" << LF; if (!is_nil (con->feed_cmd)) con->feed_cmd->apply (); // call the data processor } -- 2.11.4.GIT