17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 1989 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California. 87c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 97c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 107c478bd9Sstevel@tonic-gate */ 117c478bd9Sstevel@tonic-gate 125d54f3d8Smuffin #ifndef __sys_wait_h 135d54f3d8Smuffin #define __sys_wait_h 145d54f3d8Smuffin 157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate /* 18*63360950Smp204432 * This file holds definitions relevant to the wait system call. 197c478bd9Sstevel@tonic-gate * Some of the options here are available only through the ``wait3'' 207c478bd9Sstevel@tonic-gate * entry point; the old entry point with one argument has more fixed 217c478bd9Sstevel@tonic-gate * semantics, never returning status of unstopped children, hanging until 227c478bd9Sstevel@tonic-gate * a process terminates if any are outstanding, and never returns 237c478bd9Sstevel@tonic-gate * detailed information about process resource utilization (<vtimes.h>). 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _POSIX_SOURCE 277c478bd9Sstevel@tonic-gate #define __wait wait 287c478bd9Sstevel@tonic-gate #define w_termsig __w_termsig 297c478bd9Sstevel@tonic-gate #define w_coredump __w_coredump 307c478bd9Sstevel@tonic-gate #define w_retcode __w_retcode 317c478bd9Sstevel@tonic-gate #define w_stopval __w_stopval 327c478bd9Sstevel@tonic-gate #define w_stopsig __w_stopsig 337c478bd9Sstevel@tonic-gate #define WSTOPPED _WSTOPPED 345d54f3d8Smuffin #endif /* !_POSIX_SOURCE */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Structure of the information in the first word returned by both 387c478bd9Sstevel@tonic-gate * wait and wait3. If w_stopval==WSTOPPED, then the second structure 397c478bd9Sstevel@tonic-gate * describes the information returned, else the first. See WUNTRACED below. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate union __wait { 427c478bd9Sstevel@tonic-gate int w_status; /* used in syscall */ 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Terminated process status. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate struct { 477c478bd9Sstevel@tonic-gate unsigned short w_Fill1:16; /* high 16 bits unused */ 487c478bd9Sstevel@tonic-gate unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 497c478bd9Sstevel@tonic-gate unsigned short w_Coredump:1; /* core dump indicator */ 507c478bd9Sstevel@tonic-gate unsigned short w_Termsig:7; /* termination signal */ 517c478bd9Sstevel@tonic-gate } w_T; 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * Stopped process status. Returned 547c478bd9Sstevel@tonic-gate * only for traced children unless requested 557c478bd9Sstevel@tonic-gate * with the WUNTRACED option bit. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate struct { 587c478bd9Sstevel@tonic-gate unsigned short w_Fill2:16; /* high 16 bits unused */ 597c478bd9Sstevel@tonic-gate unsigned short w_Stopsig:8; /* signal that stopped us */ 607c478bd9Sstevel@tonic-gate unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 617c478bd9Sstevel@tonic-gate } w_S; 627c478bd9Sstevel@tonic-gate }; 637c478bd9Sstevel@tonic-gate #define __w_termsig w_T.w_Termsig 647c478bd9Sstevel@tonic-gate #define __w_coredump w_T.w_Coredump 657c478bd9Sstevel@tonic-gate #define __w_retcode w_T.w_Retcode 667c478bd9Sstevel@tonic-gate #define __w_stopval w_S.w_Stopval 677c478bd9Sstevel@tonic-gate #define __w_stopsig w_S.w_Stopsig 687c478bd9Sstevel@tonic-gate #define _WSTOPPED 0177 /* value of s.stopval if process is stopped */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * Option bits for the second argument of wait3. WNOHANG causes the 727c478bd9Sstevel@tonic-gate * wait to not hang if there are no stopped or terminated processes, rather 737c478bd9Sstevel@tonic-gate * returning an error indication in this case (pid==0). WUNTRACED 747c478bd9Sstevel@tonic-gate * indicates that the caller should receive status about untraced children 757c478bd9Sstevel@tonic-gate * which stop due to signals. If children are stopped and a wait without 767c478bd9Sstevel@tonic-gate * this option is done, it is as though they were still running... nothing 777c478bd9Sstevel@tonic-gate * about them is returned. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define WNOHANG 1 /* dont hang in wait */ 807c478bd9Sstevel@tonic-gate #define WUNTRACED 2 /* tell about stopped, untraced children */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #define WIFSTOPPED(x) (((union __wait*)&(x))->__w_stopval == _WSTOPPED) 837c478bd9Sstevel@tonic-gate #define WIFSIGNALED(x) (((union __wait*)&(x))->__w_stopval != _WSTOPPED && \ 847c478bd9Sstevel@tonic-gate ((union __wait*)&(x))->__w_termsig != 0) 857c478bd9Sstevel@tonic-gate #define WIFEXITED(x) (((union __wait*)&(x))->__w_stopval != _WSTOPPED && \ 867c478bd9Sstevel@tonic-gate ((union __wait*)&(x))->__w_termsig == 0) 877c478bd9Sstevel@tonic-gate #define WEXITSTATUS(x) (((union __wait*)&(x))->__w_retcode) 887c478bd9Sstevel@tonic-gate #define WTERMSIG(x) (((union __wait*)&(x))->__w_termsig) 897c478bd9Sstevel@tonic-gate #define WSTOPSIG(x) (((union __wait*)&(x))->__w_stopsig) 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #include <sys/stdtypes.h> 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate pid_t wait(/* int *loc */); 947c478bd9Sstevel@tonic-gate pid_t waitpid(/* pid_t pid, int *loc, int opts */); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #endif /* !__sys_wait_h */ 97