syswait.h 1.87 KB
Newer Older
Richard M. Stallman's avatar
Richard M. Stallman committed
1
/* Define wait system call interface for Emacs.
Paul Eggert's avatar
Paul Eggert committed
2
   Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
3 4 5

This file is part of GNU Emacs.

6
GNU Emacs is free software: you can redistribute it and/or modify
Richard M. Stallman's avatar
Richard M. Stallman committed
7
it under the terms of the GNU General Public License as published by
8 9
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
Richard M. Stallman's avatar
Richard M. Stallman committed
10 11 12 13 14 15 16

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

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/>.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
18 19 20 21 22

/* Define the structure that the wait system call stores.
   On many systems, there is a structure defined for this.
   But on vanilla-ish USG systems there is not.  */

23 24 25 26
#ifndef EMACS_SYSWAIT_H
#define EMACS_SYSWAIT_H

#include <sys/types.h>
Dave Love's avatar
Dave Love committed
27

Paul Eggert's avatar
Paul Eggert committed
28
#ifdef HAVE_SYS_WAIT_H	/* We have sys/wait.h with POSIXish definitions.  */
29
#include <sys/wait.h>
30 31
#endif  /* !HAVE_SYS_WAIT_H */

32 33 34 35
#ifndef WCONTINUED
#define WCONTINUED 8
#endif

Dave Love's avatar
Dave Love committed
36 37
#ifndef WCOREDUMP		/* not POSIX */
#define WCOREDUMP(status) ((status) & 0x80)
38
#endif
39
#ifndef WEXITSTATUS
Dave Love's avatar
Dave Love committed
40
#define WEXITSTATUS(status) (((status)  & 0xff00) >> 8)
41 42
#endif
#ifndef WIFEXITED
Dave Love's avatar
Dave Love committed
43
#define WIFEXITED(status) (WTERMSIG(status) == 0)
44 45
#endif
#ifndef WIFSTOPPED
Dave Love's avatar
Dave Love committed
46
#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
47 48
#endif
#ifndef WIFSIGNALED
Dave Love's avatar
Dave Love committed
49
#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
50 51
#endif
#ifndef WSTOPSIG
Dave Love's avatar
Dave Love committed
52
#define WSTOPSIG(status) WEXITSTATUS(status)
53 54
#endif
#ifndef WTERMSIG
Dave Love's avatar
Dave Love committed
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 */