* lib/wait-process.c, lib/wait-process.h, lib/csharpcomp.c,
[gnulib.git] / lib / wait-process.h
1 /* Waiting for a subprocess to finish.
2    Copyright (C) 2001-2003, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef _WAIT_PROCESS_H
20 #define _WAIT_PROCESS_H
21
22 /* Get pid_t.  */
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26
27 #include <stdbool.h>
28
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34
35 /* Wait for a subprocess to finish.  Return its exit code.
36    If it didn't terminate correctly, exit if exit_on_error is true, otherwise
37    return 127.
38    Arguments:
39    - child is the pid of the subprocess.
40    - progname is the name of the program executed by the subprocess, used for
41      error messages.
42    - If ignore_sigpipe is true, consider a subprocess termination due to
43      SIGPIPE as equivalent to a success.  This is suitable for processes whose
44      only purpose is to write to standard output.  This flag can be safely set
45      to false when the process' standard output is known to go to DEV_NULL.
46    - If null_stderr is true, the usual error message to stderr will be omitted.
47      This is suitable when the subprocess does not fulfill an important task.
48    - slave_process should be set to true if the process has been launched as a
49      slave process.
50    - If exit_on_error is true, any error will cause the main process to exit
51      with an error status.  */
52 extern int wait_subprocess (pid_t child, const char *progname,
53                             bool ignore_sigpipe, bool null_stderr,
54                             bool slave_process, bool exit_on_error);
55
56 /* Register a subprocess as being a slave process.  This means that the
57    subprocess will be terminated when its creator receives a catchable fatal
58    signal or exits normally.  Registration ends when wait_subprocess()
59    notices that the subprocess has exited.  */
60 extern void register_slave_subprocess (pid_t child);
61
62
63 #ifdef __cplusplus
64 }
65 #endif
66
67
68 #endif /* _WAIT_PROCESS_H */