Subject: Berkley make (NetBSD 1.1) and signal code???
To: None <tech-ports@NetBSD.ORG>
From: Andrew Cagney <>
List: tech-ports
Date: 02/04/1996 14:15:04

I'm going back over the notes I made for getting berkley make built on a
non bsd host (SVR4 to be exact).  One thing I've noticed in the code is
that bmake uses explicit fields of the wait status (eg x.w_termsig)
instead of using macros (eg WTERMSIG(x)).

In converting from the old (bad) to the new (good?) form so it would
build under svr4, I've come across a some what confusing bit of code.

make/compat.c contains:

	if (stat > -1) {
	    if (WIFSTOPPED(reason)) {
		status = reason.w_stopval;		/* stopped */

which I, with out thinking, converted into:

	if (stat > -1) {
	    if (WIFSTOPPED(reason)) {
		status = WSTOPSIG(reason); /* .w_stopval */ /* stopped */

However, looking at the include file sys/wait.h I find:

	#define _WSTATUS(x)     (_W_INT(x) & 0177)
	#define WIFSTOPPED(x)   (_WSTATUS(x) == _WSTOPPED)
	#define WSTOPSIG(x)     (_W_INT(x) >> 8)

and later:

                unsigned int    w_Stopval:8,    /* == W_STOPPED if stopped */
                                w_Stopsig:8,    /* signal that stopped us */

In my reading of the original C code, the above `reason.w_stopval' will
always return `_WSTOPPED'.  From this, I suspect that the original code
is wrong and should have been written as:

		status = reason.w_stopsig

Is this correct?  Comments?