rjk@sawmill.UUCP (Richard Kuhns) (01/11/89)
I've seen several patches to GNUmake 3.27 for System V drift by, and
I'd like to present my version of the necessary changes to commands.c.
My changes DO trap SIGCLD and DON'T create zombies (at least, I haven't
seen any so far), in order to make it as similar to the Berkeley code
as possible. I'm not going to bother with the changes to the variable
named `index'... note that we never want to SIG_IGN SIGCLD under SYSV,
we want to SIG_DFL so wait() will return a useable value.
*** make-3.27/commands.c Mon Dec 12 18:37:09 1988
--- commands.c Mon Jan 9 11:47:19 1989
***************
*** 22,30
#ifdef USG
#define WAIT_T int
! #define WTERMSIG(x) ((x) & 0xf7)
! #define WCOREDUMP(x) ((x) & 0x01)
! #define WRETCODE(x) ((x) & (0xff >> 8))
#define WIFSIGNALED(x) (WTERMSIG (x) != 0)
#define WIFEXITED(x) (WTERMSIG (x) == 0)
--- 22,30 -----
#ifdef USG
#define WAIT_T int
! #define WTERMSIG(x) ((x) & 0x7f)
! #define WCOREDUMP(x) ((x) & 0x0200)
! #define WRETCODE(x) (((x) >> 8) & 0xff)
#define WIFSIGNALED(x) (WTERMSIG (x) != 0)
#define WIFEXITED(x) (WTERMSIG (x) == 0)
***************
*** 38,43
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/fcntl.h>
#endif /* USG */
--- 38,46 -----
#include <sys/time.h>
#include <sys/resource.h>
+ #ifdef sequent
+ #include <fcntl.h>
+ #else
#include <sys/fcntl.h>
#endif /* sequent */
#endif /* USG */
***************
*** 39,44
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/fcntl.h>
#endif /* USG */
--- 42,48 -----
#include <fcntl.h>
#else
#include <sys/fcntl.h>
+ #endif /* sequent */
#endif /* USG */
***************
*** 151,157
if (children == 0 && shell_function_pid <= 0)
return 0;
! while (wait (&status) > 0)
#else /* not USG */
while ((sig <= 0
? (pid = wait (&status))
--- 155,161 -----
if (children == 0 && shell_function_pid <= 0)
return 0;
! while ((pid = wait (&status)) > 0)
#else /* not USG */
while ((sig <= 0
? (pid = wait (&status))
***************
*** 165,171
if (pid == shell_function_pid)
{
shell_function_pid
! = (WIFEXITED (status) && status.w_retcode == 127) ? -1 : 0;
if (sig < 0 && ++dead_children > -sig)
return 0;
--- 169,175 -----
if (pid == shell_function_pid)
{
shell_function_pid
! = (WIFEXITED (status) && WRETCODE(status) == 127) ? -1 : 0;
if (sig < 0 && ++dead_children > -sig)
return 0;
***************
*** 180,187
char buf[100];
if (WIFEXITED (status))
! if (status.w_retcode != 0)
! sprintf (buf, "*** Error %d", status.w_retcode);
else
buf[0] = '\0';
else if (WIFSIGNALED (status))
--- 184,191 -----
char buf[100];
if (WIFEXITED (status))
! if (WRETCODE(status) != 0)
! sprintf (buf, "*** Error %d", WRETCODE(status));
else
buf[0] = '\0';
else if (WIFSIGNALED (status))
***************
*** 186,194
buf[0] = '\0';
else if (WIFSIGNALED (status))
{
! char *cd = status.w_coredump ? " (core dumped)" : "";
! if (status.w_termsig > 0 && status.w_termsig < NSIG)
! sprintf (buf, "*** %s%s", sys_siglist[status.w_termsig], cd);
else
sprintf (buf, "*** Signal %d%s", status.w_termsig, cd);
}
--- 190,198 -----
buf[0] = '\0';
else if (WIFSIGNALED (status))
{
! char *cd = WCOREDUMP(status) ? " (core dumped)" : "";
! if (WTERMSIG(status) > 0 && WTERMSIG(status) < NSIG)
! sprintf (buf, "*** %s%s", sys_siglist[WTERMSIG(status)], cd);
else
sprintf (buf, "*** Signal %d%s", WTERMSIG(status), cd);
}
***************
*** 190,196
if (status.w_termsig > 0 && status.w_termsig < NSIG)
sprintf (buf, "*** %s%s", sys_siglist[status.w_termsig], cd);
else
! sprintf (buf, "*** Signal %d%s", status.w_termsig, cd);
}
else
strcpy (buf, "*** Strange Error");
--- 194,200 -----
if (WTERMSIG(status) > 0 && WTERMSIG(status) < NSIG)
sprintf (buf, "*** %s%s", sys_siglist[WTERMSIG(status)], cd);
else
! sprintf (buf, "*** Signal %d%s", WTERMSIG(status), cd);
}
else
strcpy (buf, "*** Strange Error");
***************
*** 302,308
#ifdef SIGCHLD
(void) signal (SIGCHLD, SIG_IGN);
#else
! (void) signal (SIGCLD, SIG_IGN);
#endif
/* Call child_handler to do the work. */
--- 306,312 -----
#ifdef SIGCHLD
(void) signal (SIGCHLD, SIG_IGN);
#else
! (void) signal (SIGCLD, SIG_DFL);
#endif
/* Call child_handler to do the work. */