SIGPIPE in src/view.c



Hi all (especially Leonard),

I have a patch that _could_ fix the SIGPIPE issue with mcview. Please try if it works.

Roland
Index: view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.162
diff -u -r1.162 view.c
--- view.c	25 Sep 2004 02:00:25 -0000	1.162
+++ view.c	26 Sep 2004 15:06:11 -0000
@@ -22,6 +22,8 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include <config.h>
+
+#include <signal.h>
 #include <stdio.h>
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
@@ -293,13 +295,18 @@
 					 page * sizeof (char *));
 	    for (i = view->blocks; i < page; i++) {
 		char *p = g_try_malloc (VIEW_PAGE_SIZE);
+		void (*oldsig)(int);
+
 		view->block_ptr[i] = p;
 		if (!p)
 		    return '\n';
+
+		oldsig = signal (SIGPIPE, SIG_IGN);
 		if (view->stdfile != NULL)
 		    n = fread (p, 1, VIEW_PAGE_SIZE, view->stdfile);
 		else
 		    n = mc_read (view->file, p, VIEW_PAGE_SIZE);
+		(void) signal (SIGPIPE, oldsig);
 /*
  * FIXME: Errors are ignored at this point
  * Also should report preliminary EOF


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]