New module 'wait-process'.
[gnulib.git] / lib / wait-process.h
1 /* Waiting for a subprocess to finish.
2    Copyright (C) 2001-2003 Free Software Foundation, Inc.
3    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18
19 #ifndef _WAIT_PROCESS_H
20 #define _WAIT_PROCESS_H
21
22 /* Get pid_t.  */
23 #include <stdlib.h>
24 #ifdef HAVE_UNISTD_H
25 #include <unistd.h>
26 #endif
27 #include <sys/types.h>
28
29 #include <stdbool.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 /* Wait for a subprocess to finish.  Return its exit code.
38    If it didn't terminate correctly, exit if exit_on_error is true, otherwise
39    return 127.  */
40 extern int wait_subprocess (pid_t child, const char *progname,
41                             bool null_stderr,
42                             bool slave_process, bool exit_on_error);
43
44 /* Register a subprocess as being a slave process.  This means that the
45    subprocess will be terminated when its creator receives a catchable fatal
46    signal or exits normally.  Registration ends when wait_subprocess()
47    notices that the subprocess has exited.  */
48 extern void register_slave_subprocess (pid_t child);
49
50
51 #ifdef __cplusplus
52 }
53 #endif
54
55
56 #endif /* _WAIT_PROCESS_H */