texinfo-commits
[Top][All Lists]
Advanced

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

[6154] always check for exit status of man


From: Gavin D. Smith
Subject: [6154] always check for exit status of man
Date: Wed, 25 Feb 2015 19:29:17 +0000

Revision: 6154
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6154
Author:   gavin
Date:     2015-02-25 19:29:16 +0000 (Wed, 25 Feb 2015)
Log Message:
-----------
always check for exit status of man

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/man.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-02-25 19:24:26 UTC (rev 6153)
+++ trunk/ChangeLog     2015-02-25 19:29:16 UTC (rev 6154)
@@ -1,3 +1,9 @@
+2015-02-25  Gavin Smith  <address@hidden>
+
+       * info/man.c (get_manpage_from_formatter)
+       [PIPE_USE_FORK, !PIPE_USE_FORK]: If exit status of "man" command 
+       is non-zero, throw away its output.  Report from Eli Zaretskii.
+
 2015-02-25  Eli Zaretskii  <address@hidden>
 
        * info/pcterm.c (w32_info_prep, w32_info_unprep, w32_cleanup)

Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c    2015-02-25 19:24:26 UTC (rev 6153)
+++ trunk/info/man.c    2015-02-25 19:29:16 UTC (rev 6154)
@@ -323,6 +323,7 @@
   char *formatted_page = NULL;
   int pipes[2];
   pid_t child;
+  int formatter_status = 0;
 
   /* Open a pipe to this program, read the output, and save it away
      in FORMATTED_PAGE.  The reader end of the pipe is pipes[0]; the
@@ -341,7 +342,7 @@
       close (pipes[1]);
       formatted_page = read_from_fd (pipes[0]);
       close (pipes[0]);
-      wait (NULL); /* Wait for child process to exit. */
+      wait (&formatter_status); /* Wait for child process to exit. */
     }
   else
     { /* In the child, close the read end of the pipe, make the write end
@@ -387,15 +388,17 @@
     if (fpipe == 0)
       return NULL;
     formatted_page = read_from_fd (fileno (fpipe));
-    if (pclose (fpipe) == -1)
-      {
-       if (formatted_page)
-         free (formatted_page);
-       return NULL;
-      }
+    formatter_status = pclose (fpipe);
   }
 #endif /* !PIPE_USE_FORK */
 
+  if (formatter_status != 0) /* Check for failure. */
+    {
+      if (formatted_page)
+        free (formatted_page);
+      return NULL;
+    }
+
   /* If we have the page, then clean it up. */
   if (formatted_page)
     clean_manpage (formatted_page);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]