Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi there,

        I'd like to get this into libreoffice-3-4 - I hope it is self
explanatory ;-) amused to catch this in the debugger on Linux, and see
the 100% CPU spin that injecting a bogus EPIPE causes to 'Quit'.

        ATB,

                Michael.

From 7f823d91d55900ee7d5bedbc145b280942fe0b69 Mon Sep 17 00:00:00 2001
From: Michael Meeks <michael.meeks@novell.com>
Date: Fri, 22 Jul 2011 10:58:00 +0100
Subject: [PATCH] don't let our fprintf on a broken pipe pollute errno's ECHILD with EPIPE

---
 dmake/unix/runargv.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/dmake/unix/runargv.c b/dmake/unix/runargv.c
index 4d18eff..8135e67 100644
--- a/dmake/unix/runargv.c
+++ b/dmake/unix/runargv.c
@@ -269,9 +269,10 @@ dmwaitnext( wid, status )
 
    /* If ECHILD is set from waitpid/wait then no child was left. */
    if( *wid  == -1 ) {
-      fprintf(stderr, "%s:  Internal Error: wait() failed: %d -  %s\n",
-          Pname, errno, strerror(errno) );
-      if(errno != ECHILD) {
+        int realErr = errno; // fprintf can pollute errno
+        fprintf(stderr, "%s:  Internal Error: wait() failed: %d -  %s\n",
+                        Pname, errno, strerror(errno) );
+      if( realErr != ECHILD ) {
      /* Wait was interrupted or a child was terminated (SIGCHLD) */
      return -2;
       } else {
@@ -369,9 +370,10 @@ dmwaitpid( pqid, wid, status )
    }
    /* If ECHILD is set from waitpid/wait then no child was left. */
    if( *wid  == -1 ) {
+        int realErr = errno; // fprintf can pollute errno
       fprintf(stderr, "%s:  Internal Error: waitpid() failed: %d -  %s\n",
           Pname, errno, strerror(errno) );
-      if(errno != ECHILD) {
+      if(realErr != ECHILD) {
      /* Wait was interrupted or a child was terminated (SIGCHLD) */
      return -2;
       } else {
-- 
1.7.3.4


-- 
 michael.meeks@novell.com  <><, Pseudo Engineer, itinerant idiot



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.