#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__
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,
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);
+ }
}
}
}
#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
+
/* Add prototype support. */
#ifndef PROTO
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
if (commands[j].pid == pid)
prog = commands[j].prog;
- if ((status & 0x7F) != 0)
+ if (WIFSIGNALED (status))
{
fatal ("Internal compiler error: program %s got fatal signal %d",
- prog, (status & 0x7F));
+ prog, WTERMSIG (status));
signal_count++;
+ ret_code = -1;
}
- if (((status & 0xFF00) >> 8) >= MIN_FATAL_STATUS)
+ else if (WIFEXITED (status)
+ && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
ret_code = -1;
}
}
#define O_RDONLY 0
#define O_WRONLY 1
+#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
+
/* Declaring stat or __flsbuf with a prototype
causes conflicts with system headers on some systems. */
pname, sys_errlist[errno]);
return 0;
}
- if ((wait_status & 0x7F) != 0)
+ if (WIFSIGNALED (wait_status))
{
fprintf (stderr, "%s: subprocess got fatal signal %d",
- pname, (wait_status & 0x7F));
+ pname, WTERMSIG (wait_status));
return 0;
}
- if (((wait_status & 0xFF00) >> 8) != 0)
+ if (WIFEXITED (wait_status) && WEXITSTATUS (wait_status) != 0)
{
fprintf (stderr, "%s: %s exited with status %d\n",
- pname, base_filename, ((wait_status & 0xFF00) >> 8));
+ pname, base_filename, WEXITSTATUS (wait_status));
return 0;
}
return 1;