[gnu.bash.bug] bash 1.04 on System V 3.2

jjc@relay.eu.net (James Clark) (12/03/89)

I tried compiling bash 1.04 on a 386 PC running 386/ix 2.0.1 (a
variant of System V.3.2).

I think somebody already mentioned that it is necessary to add -DUSGr3
to CFLAGS.

When i386 is defined, jobs.h defines w_termsig as follows:

#define w_termsig bytes.low & 0x7f

nojobs.c includes the line

	  status.w_termsig = status.w_retcode = 0;

This won't compile. It also includes the line

  if (status.w_termsig != 0 && status.w_termsig != WSTOPPED)

This will always be 0.  The effect of this is that bash does not
report processes that are terminated by signals.

I fixed these problems by modifying jobs.h and config.h as follows:

*** jobs.h.dist	Sat Dec  2 14:42:08 1989
--- jobs.h	Sat Dec  2 16:33:07 1989
***************
*** 2,34 ****
  
  #include "quit.h"
  
- #if !defined (SYSV) || defined (UNIXPC)
- #include <sys/wait.h>
- #else
- 
- #if defined (i386) || defined (ATT3B) || defined (ATT386)
- 
- union wait {
-   struct {
-     unsigned char low;
-     unsigned char high;
-   }
-   bytes;
-   short word;
- };
- 
- #define WSTOPPED 0177
- #define w_status word
- #define w_termsig bytes.low & 0x7f
- #define w_stopsig bytes.high
- #define w_retcode bytes.high
- #define w_coredump w_termsig & ~0x7f
- #define WIFEXITED(wstat) ((wstat).bytes.low == 0)
- #define WIFSTOPPED(wstat) ((wstat).bytes.low == 0177)
- #define WIFTERMINATED(wstat) ((wstat).bytes.high == 0)
- 
- #else  /* i386 || ATT3B || ATT386 */
- 
  #ifdef NO_WAIT_H
  union wait
    {
--- 2,7 ----
***************
*** 38,47 ****
--- 11,26 ----
      struct
        {
  	unsigned short
+ #if defined (i386) || defined (ATT3B) || defined (ATT386)
+ 	  w_Termsig  : 7,	/* termination signal */
+ 	  w_Coredump : 1,	/* core dump indicator */
+ 	  w_Retcode  : 8;	/* exit code if w_termsig==0 */
+ #else
  	  w_Fill1    : 16,	/* high 16 bits unused */
  	  w_Retcode  : 8,	/* exit code if w_termsig==0 */
  	  w_Coredump : 1,	/* core dump indicator */
  	  w_Termsig  : 7;	/* termination signal */
+ #endif /* defined (i386) || defined (ATT3B) || defined (ATT386) */
        } w_T;
  
      /* Stopped process status.  Returned
***************
*** 50,58 ****
--- 29,42 ----
      struct
        {
  	unsigned short
+ #if defined (i386) || defined (ATT3B) || defined (ATT386)
+ 	  w_Stopval : 8,	/* == W_STOPPED if stopped */
+ 	  w_Stopsig : 8;	/* signal that stopped us */
+ #else
  	  w_Fill2   : 16,	/* high 16 bits unused */
  	  w_Stopsig : 8,	/* signal that stopped us */
  	  w_Stopval : 8;	/* == W_STOPPED if stopped */
+ #endif /* defined (i386) || defined (ATT3B) || defined (ATT386) */
        } w_S;
    };
  
***************
*** 67,75 ****
  #define WIFEXITED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) == 0))
  #define WIFSIGNALED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) != 0))
  
! #endif  /* HPUX */
! #endif  /* i386 || ATT3B || ATT386 */
! #endif  /* !defined (SYSV) || defined (UNIXPC) */
  
  /* I looked it up.  For pretty_print_job ().  The real answer is 24. */
  #define LONGEST_SIGNAL_DESC 20
--- 51,59 ----
  #define WIFEXITED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) == 0))
  #define WIFSIGNALED(x) ((! (WIFSTOPPED (x))) && (((x) . w_termsig) != 0))
  
! #else
! #include <sys/wait.h>
! #endif  /* NO_WAIT_H */
  
  /* I looked it up.  For pretty_print_job ().  The real answer is 24. */
  #define LONGEST_SIGNAL_DESC 20



*** config.h.dist	Sat Dec  2 16:10:34 1989
--- config.h	Sat Dec  2 16:12:08 1989
***************
*** 66,72 ****
  
  /* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
     This is true for HPUX and ALTOS. */
! #if defined (HPUX) || defined (ALTOS)
  #define NO_WAIT_H
  #endif
  
--- 66,72 ----
  
  /* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
     This is true for HPUX and ALTOS. */
! #if defined (HPUX) || defined (ALTOS) || (defined (SYSV) && !defined (UNIXPC))
  #define NO_WAIT_H
  #endif
  

James Clark
jjc@jclark.uucp