2011-10-06 Christian Franke <franke@computer.org>

* include/cygwin/wait.h: Use new __wait_status_to_int()
	macro to access status value in W*() status checks.
	Fix status description.
	* include/sys/wait.h: Allow `int' and `union wait' as
	wait status parameter.  Change __wait_status_to_int()
	macro and wait () prototypes accordingly.  Add inline
	functions for C++.  Remove extra `;'.
This commit is contained in:
Christian Franke
2011-10-06 16:02:37 +00:00
parent e402890df2
commit efe716bb8e
3 changed files with 73 additions and 17 deletions

View File

@ -1,6 +1,6 @@
/* cygwin/wait.h
Copyright 2006, 2009 Red Hat, Inc.
Copyright 2006, 2009, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -16,8 +16,11 @@ details. */
#define WCONTINUED 8
#define __W_CONTINUED 0xffff
/* A status looks like:
<2 bytes info> <2 bytes code>
/* Will be redefined in sys/wait.h. */
#define __wait_status_to_int(w) (w)
/* A status is 16 bits, and looks like:
<1 byte info> <1 byte code>
<code> == 0, child has exited, info is the exit value
<code> == 1..7e, child has exited, info is the signal number.
@ -25,13 +28,14 @@ details. */
<code> == 80, there was a core dump.
*/
#define WIFEXITED(w) (((w) & 0xff) == 0)
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
#define WIFCONTINUED(w) (((w) & 0xffff) == __W_CONTINUED)
#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
#define WTERMSIG(w) ((w) & 0x7f)
#define WIFEXITED(w) ((__wait_status_to_int(w) & 0xff) == 0)
#define WIFSIGNALED(w) ((__wait_status_to_int(w) & 0x7f) > 0 \
&& ((__wait_status_to_int(w) & 0x7f) < 0x7f))
#define WIFSTOPPED(w) ((__wait_status_to_int(w) & 0xff) == 0x7f)
#define WIFCONTINUED(w) ((__wait_status_to_int(w) & 0xffff) == __W_CONTINUED)
#define WEXITSTATUS(w) ((__wait_status_to_int(w) >> 8) & 0xff)
#define WTERMSIG(w) (__wait_status_to_int(w) & 0x7f)
#define WSTOPSIG WEXITSTATUS
#define WCOREDUMP(w) (WIFSIGNALED(w) && (w & 0x80))
#define WCOREDUMP(w) (WIFSIGNALED(w) && (__wait_status_to_int(w) & 0x80))
#endif /* _CYGWIN_WAIT_H */