delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/09/01/06:14:24

Date: Sun, 1 Sep 1996 13:13:38 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
Subject: Termination codes of child programs
Message-Id: <Pine.SUN.3.91.960901130618.22009A-100000@is>
Mime-Version: 1.0

When a program launches a child program, it expects (on Unix) to get both
its exit code and the signal, if any, that aborted that child.  Our
<sys/wait.h> doesn't support extraction of the signal from the status
returned by `system' and `spawnXX'.  I used to hack the necessary defines
into the programs' code, but after I found myself doing it for the third
program in a row (find, xargs, and now Make), I think it's time to make it
official.  Especially, since the latest version of `dosexec' already puts
SIGINT into the return status when the child was aborted with Ctrl-C. 

So how about the following change:

*** include/sys/wait.h~0	Wed Aug 23 07:57:50 1995
--- include/sys/wait.h	Sat Aug 31 19:05:18 1996
***************
*** 12,24 ****
  
  #include <sys/djtypes.h>
  
! #define WEXITSTATUS(stat_val)	(  (stat_val) & 0x00ff)
! #define WIFEXITED(stat_val)	(!((stat_val) & 0xff00))
! #define WIFSIGNALED(stat_val)	( ((stat_val) & 0xff00))
  #define WIFSTOPPED(stat_val)	0
  #define WNOHANG			1
  #define WSTOPSIG(stat_val)	0
! #define WTERMSIG(stat_val)	(  (stat_val) & 0x00ff)
  #define WUNTRACED
  
  __DJ_pid_t
--- 12,24 ----
  
  #include <sys/djtypes.h>
  
! #define WEXITSTATUS(stat_val)	(  (stat_val) & 0x000ff)
! #define WIFEXITED(stat_val)	(!((stat_val) & 0x3ff00))
! #define WIFSIGNALED(stat_val)	( ((stat_val) & 0x3ff00))
  #define WIFSTOPPED(stat_val)	0
  #define WNOHANG			1
  #define WSTOPSIG(stat_val)	0
! #define WTERMSIG(stat_val)	( ((stat_val) >> 8 ) & 0x3ff)
  #define WUNTRACED
  
  __DJ_pid_t

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019