Mercurial > octave-libtiff
changeset 21527:ab8760b1245d
Raise an error if writes to pipe fail (bug #47381).
* gl2ps-print.cc: Re-order #includes.
* gl2ps-print.cc (gl2ps_renderer::draw): When copying temporary file to pipe,
check that write succeeds by comparing bytes read to bytes written. If an
error has occured, clear the SIGPIPE signal by calling octave_signal_handler
and then raise an error.
letting SIGPIPE interrupt handler eventually deal with the problem.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 22 Mar 2016 15:17:18 -0700 |
parents | b76d1de20f9a |
children | ffbd3e86e0be |
files | libinterp/corefcn/gl2ps-print.cc |
diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc Tue Mar 22 14:36:15 2016 -0700 +++ b/libinterp/corefcn/gl2ps-print.cc Tue Mar 22 15:17:18 2016 -0700 @@ -25,14 +25,11 @@ #endif #include "errwarn.h" -#include "gl2ps-print.h" #ifdef HAVE_GL2PS_H #include <cstdio> - #include <limits> - #include <unistd.h> #include <gl2ps.h> @@ -41,8 +38,10 @@ #include "oct-locbuf.h" #include "unwind-prot.h" +#include "gl2ps-print.h" #include "gl-render.h" #include "oct-opengl.h" +#include "sighandlers.h" #include "sysdep.h" #include "text-renderer.h" @@ -269,12 +268,20 @@ // Copy temporary file to pipe gnulib::fseek (tmpf, 0, SEEK_SET); char str[256]; - int nread = 1; + size_t nread, nwrite; + nread = 1; while (! feof (tmpf) && nread) { nread = gnulib::fread (str, 1, 256, tmpf); if (nread) - gnulib::fwrite (str, 1, nread, fp); + { + nwrite = gnulib::fwrite (str, 1, nread, fp); + if (nwrite != nread) + { + octave_signal_handler (); // Clear SIGPIPE signal + error ("gl2ps_renderer::draw: internal pipe error"); + } + } } } else