bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [Bug] sdiff-2.8.1: wrong subsidiary program check


From: Paul Eggert
Subject: Re: [Bug] sdiff-2.8.1: wrong subsidiary program check
Date: Thu, 5 Sep 2002 02:19:22 -0700 (PDT)

> From: Takashi Matsuda <address@hidden>
> Date: Thu, 5 Sep 2002 17:24:03 +0900

> In this case, waitpid() stored 256 into wstatus.

OK, thanks, I think I see the problem now.  Please try this patch,
relative to sdiff 2.8.1.


--- sdiff.c-2.8.1       2002-03-11 00:00:47.000000000 -0800
+++ sdiff.c     2002-09-05 02:16:47.798736792 -0700
@@ -261,22 +261,19 @@ perror_fatal (char const *msg)
 }
 
 static void
-ck_editor_status (int errnum, int status)
+ck_editor_status (int errnum, int status, int max_ok_status)
 {
-  if (errnum | status)
+  int s = WIFEXITED (status) ? WEXITSTATUS (status) : 128;
+
+  if (max_ok_status < s)
     {
-      char const *failure_msgid = N_("subsidiary program `%s' failed");
-      if (! errnum && WIFEXITED (status))
-       switch (WEXITSTATUS (status))
-         {
-         case 126:
-           failure_msgid = N_("subsidiary program `%s' not executable");
-           break;
-         case 127:
-           failure_msgid = N_("subsidiary program `%s' not found");
-           break;
-         }
-      error (0, errnum, _(failure_msgid), editor_program);
+      error (0, errnum,
+            _(errnum || s < 126 || 127 < s
+              ? "subsidiary program `%s' failed"
+              : s == 126
+              ? "subsidiary program `%s' could not be invoked"
+              : "subsidiary program `%s' not found"),
+            editor_program);
       exiterr ();
     }
 }
@@ -664,7 +661,7 @@ main (int argc, char *argv[])
              }
 
            execvp (diffargv[0], (char **) diffargv);
-           _exit (errno == ENOEXEC ? 126 : 127);
+           _exit (errno == ENOENT ? 127 : 126);
          }
 
 # if HAVE_WORKING_VFORK
@@ -724,7 +721,7 @@ main (int argc, char *argv[])
        if (! interact_ok)
          exiterr ();
 
-       ck_editor_status (werrno, wstatus);
+       ck_editor_status (werrno, wstatus, EXIT_FAILURE);
        untrapsig (0);
        checksigs ();
        exit (WEXITSTATUS (wstatus));
@@ -1072,7 +1069,7 @@ edit (struct line_filter *left, char con
                    argv[i] = 0;
 
                    execvp (editor_program, (char **) argv);
-                   _exit (errno == ENOEXEC ? 126 : 127);
+                   _exit (errno == ENOENT ? 127 : 126);
                  }
 
                if (pid < 0)
@@ -1087,7 +1084,7 @@ edit (struct line_filter *left, char con
              }
 
              ignore_SIGINT = 0;
-             ck_editor_status (werrno, wstatus);
+             ck_editor_status (werrno, wstatus, EXIT_SUCCESS);
            }
 
            {




reply via email to

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