home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / wait.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  6.5 KB  |  193 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    wait.h,v $
  29.  * Revision 2.1  92/04/21  17:17:18  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)wait.h    7.17 (Berkeley) 6/19/91
  68.  */
  69.  
  70. /*
  71.  * This file holds definitions relevent to the wait4 system call
  72.  * and the alternate interfaces that use it (wait, wait3, waitpid).
  73.  */
  74.  
  75. /*
  76.  * Macros to test the exit status returned by wait
  77.  * and extract the relevant values.
  78.  */
  79. #ifdef _POSIX_SOURCE
  80. #define    _W_INT(i)    (i)
  81. #else
  82. #define    _W_INT(w)    (*(int *)&(w))    /* convert union wait to int */
  83. #define    WCOREFLAG    0200
  84. #endif
  85.  
  86. #define    _WSTATUS(x)    (_W_INT(x) & 0177)
  87. #define    _WSTOPPED    0177        /* _WSTATUS if process is stopped */
  88. #define WIFSTOPPED(x)    (_WSTATUS(x) == _WSTOPPED)
  89. #define WSTOPSIG(x)    (_W_INT(x) >> 8)
  90. #define WIFSIGNALED(x)    (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
  91. #define WTERMSIG(x)    (_WSTATUS(x))
  92. #define WIFEXITED(x)    (_WSTATUS(x) == 0)
  93. #define WEXITSTATUS(x)    (_W_INT(x) >> 8)
  94. #ifndef _POSIX_SOURCE
  95. #define WCOREDUMP(x)    (_W_INT(x) & WCOREFLAG)
  96.  
  97. #define    W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
  98. #define    W_STOPCODE(sig)        ((sig) << 8 | _WSTOPPED)
  99. #endif
  100.  
  101. /*
  102.  * Option bits for the second argument of wait4.  WNOHANG causes the
  103.  * wait to not hang if there are no stopped or terminated processes, rather
  104.  * returning an error indication in this case (pid==0).  WUNTRACED
  105.  * indicates that the caller should receive status about untraced children
  106.  * which stop due to signals.  If children are stopped and a wait without
  107.  * this option is done, it is as though they were still running... nothing
  108.  * about them is returned.
  109.  */
  110. #define WNOHANG        1    /* dont hang in wait */
  111. #define WUNTRACED    2    /* tell about stopped, untraced children */
  112.  
  113. #ifndef _POSIX_SOURCE
  114. /* POSIX extensions and 4.2/4.3 compatability: */
  115.  
  116. /*
  117.  * Tokens for special values of the "pid" parameter to wait4.
  118.  */
  119. #define    WAIT_ANY    (-1)    /* any process */
  120. #define    WAIT_MYPGRP    0    /* any process in my process group */
  121.  
  122. #ifndef BYTE_ORDER
  123. #include <machine/endian.h>
  124. #endif
  125.  
  126. /*
  127.  * Deprecated:
  128.  * Structure of the information in the status word returned by wait4.
  129.  * If w_stopval==WSTOPPED, then the second structure describes
  130.  * the information returned, else the first.
  131.  */
  132. union wait {
  133.     int    w_status;        /* used in syscall */
  134.     /*
  135.      * Terminated process status.
  136.      */
  137.     struct {
  138. #if BYTE_ORDER == LITTLE_ENDIAN 
  139.         unsigned int    w_Termsig:7,    /* termination signal */
  140.                 w_Coredump:1,    /* core dump indicator */
  141.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  142.                 w_Filler:16;    /* upper bits filler */
  143. #endif
  144. #if BYTE_ORDER == BIG_ENDIAN 
  145.         unsigned int    w_Filler:16,    /* upper bits filler */
  146.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  147.                 w_Coredump:1,    /* core dump indicator */
  148.                 w_Termsig:7;    /* termination signal */
  149. #endif
  150.     } w_T;
  151.     /*
  152.      * Stopped process status.  Returned
  153.      * only for traced children unless requested
  154.      * with the WUNTRACED option bit.
  155.      */
  156.     struct {
  157. #if BYTE_ORDER == LITTLE_ENDIAN 
  158.         unsigned int    w_Stopval:8,    /* == W_STOPPED if stopped */
  159.                 w_Stopsig:8,    /* signal that stopped us */
  160.                 w_Filler:16;    /* upper bits filler */
  161. #endif
  162. #if BYTE_ORDER == BIG_ENDIAN 
  163.         unsigned int    w_Filler:16,    /* upper bits filler */
  164.                 w_Stopsig:8,    /* signal that stopped us */
  165.                 w_Stopval:8;    /* == W_STOPPED if stopped */
  166. #endif
  167.     } w_S;
  168. };
  169. #define    w_termsig    w_T.w_Termsig
  170. #define w_coredump    w_T.w_Coredump
  171. #define w_retcode    w_T.w_Retcode
  172. #define w_stopval    w_S.w_Stopval
  173. #define w_stopsig    w_S.w_Stopsig
  174.  
  175. #define    WSTOPPED    _WSTOPPED
  176. #endif /* _POSIX_SOURCE */
  177.  
  178. #ifndef KERNEL
  179. #include <sys/types.h>
  180. #include <sys/cdefs.h>
  181.  
  182. __BEGIN_DECLS
  183. struct rusage;    /* forward declaration */
  184.  
  185. pid_t    wait __P((int *));
  186. pid_t    waitpid __P((pid_t, int *, int));
  187. #ifndef _POSIX_SOURCE
  188. pid_t    wait3 __P((int *, int, struct rusage *));
  189. pid_t    wait4 __P((pid_t, int *, int, struct rusage *));
  190. #endif
  191. __END_DECLS
  192. #endif
  193.