home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / sys / h / wait < prev   
Encoding:
Text File  |  2004-09-05  |  2.8 KB  |  98 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/wait.h,v $
  4.  * $Date: 2004/04/17 10:51:15 $
  5.  * $Revision: 1.5 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* POSIX Standard 3.2.1: Wait for Process Termination <sys/wait.h>.  */
  12.  
  13. #ifndef    __SYS_WAIT_H
  14. #define    __SYS_WAIT_H 1
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <unixlib/features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. #define __need_rusage
  25. #include <sys/resource.h>
  26.  
  27. __BEGIN_DECLS
  28.  
  29. /* Bits in the third arguent to waitpid.  */
  30. #define WNOHANG 1 /* Don't block waiting.  */
  31. #define WUNTRACED 2 /* Report status of stopped children.  */
  32.  
  33. /* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
  34. #define    __WEXITSTATUS(status)    (((status) & 0xff00) >> 8)
  35.  
  36. /* If WIFSIGNALED(STATUS), the terminating signal.  */
  37. #define    __WTERMSIG(status)    ((status) & 0x7f)
  38.  
  39. /* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
  40. #define    __WSTOPSIG(status)    __WEXITSTATUS(status)
  41.  
  42. /* Nonzero if STATUS indicates normal termination.  */
  43. #define    __WIFEXITED(status)    (__WTERMSIG(status) == 0)
  44.  
  45. /* Nonzero if STATUS indicates termination by a signal.  */
  46. #define    __WIFSIGNALED(status)    (!__WIFSTOPPED(status) && !__WIFEXITED(status))
  47.  
  48. /* Nonzero if STATUS indicates the child is stopped.  */
  49. #define    __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
  50.  
  51. /* Nonzero if STATUS indicates the child dumped core.  */
  52. #define    __WCOREDUMP(status)    ((status) & __WCOREFLAG)
  53.  
  54. /* Macros for constructing status values.  */
  55. #define    __W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
  56. #define    __W_STOPCODE(sig)    ((sig) << 8 | 0x7f)
  57. #define    __WCOREFLAG        0x80
  58.  
  59.  
  60. #define    WEXITSTATUS(status)    __WEXITSTATUS(status)
  61. #define    WTERMSIG(status)    __WTERMSIG(status)
  62. #define    WSTOPSIG(status)    __WSTOPSIG(status)
  63. #define    WIFEXITED(status)    __WIFEXITED(status)
  64. #define    WIFSIGNALED(status)    __WIFSIGNALED(status)
  65. #define    WIFSTOPPED(status)    __WIFSTOPPED(status)
  66.  
  67. #define    WCOREFLAG        __WCOREFLAG
  68. #define    WCOREDUMP(status)    __WCOREDUMP(status)
  69. #define    W_EXITCODE(ret, sig)    __W_EXITCODE(ret, sig)
  70. #define    W_STOPCODE(sig)        __W_STOPCODE(sig)
  71.  
  72.  
  73. /* Wait for a child to die.  */
  74. extern __pid_t wait (int *);
  75.  
  76. /* Special values for the pid argument to `waitpid' and `wait4'.  */
  77. /* Any process.  */
  78. #define    WAIT_ANY (-1)
  79. /* Any process in my process group.  */
  80. #define    WAIT_MYPGRP 0
  81.  
  82. /* Wait for a child matching PID to die.  */
  83. extern __pid_t waitpid (__pid_t, int *, int) __THROW;
  84.  
  85. #ifndef __SYS_RESOURCE_H
  86. struct rusage;
  87. #endif
  88.  
  89. /* Wait for a child to exit.  */
  90. extern __pid_t wait3 (int *, int, struct rusage *) __THROW;
  91.  
  92. /* Wait for a child matching pid_t to die and return its usage statistics. */
  93. extern __pid_t wait4 (__pid_t, int *, int, struct rusage *) __THROW;
  94.  
  95. __END_DECLS
  96.  
  97. #endif /* sys/wait.h  */
  98.