]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc-ar.c (main): Handle the returning of the sub-process error code correctly.
authorMeador Inge <meadori@codesourcery.com>
Thu, 27 Sep 2012 16:05:38 +0000 (16:05 +0000)
committerMeador Inge <meadori@gcc.gnu.org>
Thu, 27 Sep 2012 16:05:38 +0000 (16:05 +0000)
2012-09-27  Meador Inge  <meadori@codesourcery.com>

* gcc-ar.c (main): Handle the returning of the sub-process error
code correctly.

From-SVN: r191809

gcc/ChangeLog
gcc/gcc-ar.c

index fe86a66f6bf90ae5f099b943497e769b254c33e5..20217ba69b3787c46596223fa4d0675a051970a6 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-27  Meador Inge  <meadori@codesourcery.com>
+
+       * gcc-ar.c (main): Handle the returning of the sub-process error
+       code correctly.
+
 2012-09-27  Ulrich Weigand  <ulrich.weigand@linaro.org>
 
        * lower-subreg.c (enum classify_move_insn): Rename
index caae1670bf6012dd0c3231b45a05eac9903050ce..5f78378dea86ff09f1182b0f188ac9d8dd86b865 100644 (file)
@@ -42,6 +42,7 @@ main(int ac, char **av)
   const char *err_msg;
   const char **nargv;
   bool is_ar = !strcmp (PERSONALITY, "ar");
+  int exit_code = FATAL_EXIT_CODE;
 
   exe_name = PERSONALITY;
 #ifdef CROSS_DIRECTORY_STRUCTURE
@@ -96,6 +97,20 @@ main(int ac, char **av)
                     NULL,NULL,  &status, &err);
   if (err_msg) 
     fprintf(stderr, "Error running %s: %s\n", exe_name, err_msg);
+  else if (status)
+    {
+      if (WIFSIGNALED (status))
+       {
+         int sig = WTERMSIG (status);
+         fprintf (stderr, "%s terminated with signal %d [%s]%s\n",
+                  exe_name, sig, strsignal(sig),
+                  WCOREDUMP(status) ? ", core dumped" : "");
+       }
+      else if (WIFEXITED (status))
+       exit_code = WEXITSTATUS (status);
+    }
+  else
+    exit_code = SUCCESS_EXIT_CODE;
 
-  return err;
+  return exit_code;
 }