Mercurial > hg > octave-terminal
changeset 2197:680ce730f0c6
[project @ 1996-05-15 00:03:19 by jwe]
author | jwe |
---|---|
date | Wed, 15 May 1996 00:04:37 +0000 |
parents | 0dff6c159542 |
children | d2653a9730e9 |
files | src/pager.cc src/sighandlers.cc |
diffstat | 2 files changed, 44 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pager.cc +++ b/src/pager.cc @@ -76,6 +76,21 @@ static int really_flush_to_pager = 0; static void +clear_external_pager (void) +{ + octave_pager_pid = -1; + + delete external_pager; + external_pager = 0; + + if (saved_sigint_handler) + { + octave_set_signal_handler (SIGINT, saved_sigint_handler); + saved_sigint_handler = 0; + } +} + +static void do_sync (const char *msg, bool bypass_pager) { if (! error_state) @@ -104,24 +119,20 @@ if (external_pager) { - *external_pager << msg; - - if (external_pager->fail ()) + if (octave_pager_pid > 0 && external_pager->good ()) { - octave_pager_pid = -1; - - delete external_pager; - external_pager = 0; + *external_pager << msg; - if (saved_sigint_handler) - { - octave_set_signal_handler (SIGINT, - saved_sigint_handler); - saved_sigint_handler = 0; - } + // These checks are needed if a signal handler + // invoked since the last set of checks attempts + // to flush output and then returns + + if (octave_pager_pid > 0 + && external_pager + && external_pager->good ()) + external_pager->flush (); } - else - external_pager->flush (); + clear_external_pager (); } else cout << msg; @@ -256,18 +267,7 @@ octave_stdout.flush (); if (external_pager) - { - octave_pager_pid = -1; - - delete external_pager; - external_pager = 0; - - if (saved_sigint_handler) - { - octave_set_signal_handler (SIGINT, saved_sigint_handler); - saved_sigint_handler = 0; - } - } + clear_external_pager (); run_unwind_frame ("flush_octave_stdout"); }
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -146,17 +146,26 @@ octave_set_signal_handler (SIGCHLD, sigchld_handler); - int status; - pid_t pid = wait (&status); - - if (pid > 0) + if (octave_pager_pid > 0) { - if (WIFEXITED (status) || WIFSIGNALLED (status)) + int status; + pid_t pid = waitpid (octave_pager_pid, &status, 0); + + if (pid > 0) { - if (pid == octave_pager_pid) + if (WIFEXITED (status) || WIFSIGNALLED (status)) { - error ("connection to external pager lost --"); - error ("pending computations have been discarded\n"); + octave_pager_pid = -1; + + // XXX FIXME XXX -- I'm not sure that this is the right + // thing to do here, but it seems to work. + + // Don't call error() here because that tries to flush + // pending output, which isn't going to do anything + // anyway. + + cerr << "error: connection to external pager lost --\n"; + cerr << "error: pending computations and output have been discarded\n"; } } }