summaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>1994-10-04 20:53:02 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>1994-10-04 20:53:02 +0000
commitb7826aaee52674cab554325a53956b377149c325 (patch)
tree8a014280d417c4ddd255ddba5eab01de2180301a /gcc/collect2.c
parent2cf8495e2e4d60638c76ce538780ff42761d6c2c (diff)
downloadgcc-b7826aaee52674cab554325a53956b377149c325.tar.gz
If the POSIX.1 wait macros are defined, use them.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@8213 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 8b98be6168f..d810aca6e06 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -79,6 +79,19 @@ extern int sys_nerr;
#define X_OK 1
#endif
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
+#endif
+#ifndef WTERMSIG
+#define WTERMSIG(S) ((S) & 0x7f)
+#endif
+#ifndef WIFEXITED
+#define WIFEXITED(S) (((S) & 0xff) == 0)
+#endif
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
+#endif
+
/* On MSDOS, write temp files in current dir
because there's no place else we can expect to use. */
#ifdef __MSDOS__
@@ -1254,11 +1267,9 @@ do_wait (prog)
wait (&status);
if (status)
{
- int sig = status & 0x7F;
- int ret;
-
- if (sig != -1 && sig != 0)
+ if (WIFSIGNALED (status))
{
+ int sig = WTERMSIG (status);
#ifdef NO_SYS_SIGLIST
error ("%s terminated with signal %d %s",
prog,
@@ -1275,11 +1286,14 @@ do_wait (prog)
my_exit (127);
}
- ret = ((status & 0xFF00) >> 8);
- if (ret != -1 && ret != 0)
+ if (WIFEXITED (status))
{
- error ("%s returned %d exit status", prog, ret);
- my_exit (ret);
+ int ret = WEXITSTATUS (status);
+ if (ret != 0)
+ {
+ error ("%s returned %d exit status", prog, ret);
+ my_exit (ret);
+ }
}
}
}