# HG changeset patch # User Rik # Date 1458685038 25200 # Node ID ab8760b1245dfebc543bb558d5673c21de7c74ac # Parent b76d1de20f9afeba137bc6a6525687f3c171e877 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. diff -r b76d1de20f9a -r ab8760b1245d libinterp/corefcn/gl2ps-print.cc --- 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 - #include - #include #include @@ -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