Mercurial > hg > octave-nkf
diff src/toplev.cc @ 4489:a90c3cbded0d
[project @ 2003-08-28 16:08:26 by jwe]
author | jwe |
---|---|
date | Thu, 28 Aug 2003 16:08:26 +0000 |
parents | 0bca8443db39 |
children | 93ad80b6eef6 |
line wrap: on
line diff
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -25,6 +25,7 @@ #endif #include <cassert> +#include <cerrno> #include <cstdlib> #include <cstring> #include <new> @@ -382,29 +383,29 @@ { OSSTREAM output_buf; - // XXX FIXME XXX -- sometimes, the subprocess hasn't written - // anything before we try to read from the procstream. The - // kluge below (simply waiting and trying again) is ugly, - // but it seems to work, at least most of the time. It - // could probably still fail if the subprocess hasn't - // started writing after the snooze. Isn't there a better - // way? If there is, you should also fix the code for the - // ls function in dirfns.cc. + // XXX FIXME XXX -- Perhaps we should read more than one + // character at a time and find a way to avoid the call to + // octave_usleep as well? char ch; - if (cmd->get (ch)) - output_buf.put (ch); - else + for (;;) { - cmd->clear (); + if (cmd->get (ch)) + output_buf.put (ch); + else + { + if (! cmd->eof () && errno == EAGAIN) + { + cmd->clear (); - octave_usleep (100); + octave_usleep (100); + } + else + break; + } } - while (cmd->get (ch)) - output_buf.put (ch); - int cmd_status = cmd->close (); if (WIFEXITED (cmd_status))