1 /* Define wait system call interface for Emacs. 2 Copyright (C) 1993-1995, 2000-2023 Free Software Foundation, Inc. 3 4 This file is part of GNU Emacs. 5 6 GNU Emacs is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or (at 9 your option) any later version. 10 11 GNU Emacs is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ 18 19 /* Define the structure that the wait system call stores. 20 On many systems, there is a structure defined for this. 21 But on vanilla-ish USG systems there is not. */ 22 23 #ifndef EMACS_SYSWAIT_H 24 #define EMACS_SYSWAIT_H 25 26 #include <sys/types.h> 27 28 #ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXish definitions. */ 29 #include <sys/wait.h> 30 #endif /* !HAVE_SYS_WAIT_H */ 31 32 #ifndef WCONTINUED 33 #define WCONTINUED 8 34 #endif 35 36 #ifndef WCOREDUMP /* not POSIX */ 37 #define WCOREDUMP(status) ((status) & 0x80) 38 #endif 39 #ifndef WEXITSTATUS 40 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) 41 #endif 42 #ifndef WIFEXITED 43 #define WIFEXITED(status) (WTERMSIG(status) == 0) 44 #endif 45 #ifndef WIFSTOPPED 46 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) 47 #endif 48 #ifndef WIFSIGNALED 49 #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status)) 50 #endif 51 #ifndef WSTOPSIG 52 #define WSTOPSIG(status) WEXITSTATUS(status) 53 #endif 54 #ifndef WTERMSIG 55 #define WTERMSIG(status) ((status) & 0x7f) 56 #endif 57 58 /* Defined in sysdep.c. */ 59 extern bool wait_for_termination (pid_t, int *, bool); 60 extern pid_t child_status_changed (pid_t, int *, int); 61 62 #endif /* EMACS_SYSWAIT_H */