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.
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)
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.
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. */
19 #ifndef _WAIT_PROCESS_H
20 #define _WAIT_PROCESS_H
27 #include <sys/types.h>
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
41 - child is the pid of the subprocess.
42 - progname is the name of the program executed by the subprocess, used for
44 - If ignore_sigpipe is true, consider a subprocess termination due to
45 SIGPIPE as equivalent to a success. This is suitable for processes whose
46 only purpose is to write to standard output. This flag can be safely set
47 to false when the process' standard output is known to go to DEV_NULL.
48 - If null_stderr is true, the usual error message to stderr will be omitted.
49 This is suitable when the subprocess does not fulfill an important task.
50 - slave_process should be set to true if the process has been launched as a
52 - If exit_on_error is true, any error will cause the main process to exit
53 with an error status. */
54 extern int wait_subprocess (pid_t child
, const char *progname
,
55 bool ignore_sigpipe
, bool null_stderr
,
56 bool slave_process
, bool exit_on_error
);
58 /* Register a subprocess as being a slave process. This means that the
59 subprocess will be terminated when its creator receives a catchable fatal
60 signal or exits normally. Registration ends when wait_subprocess()
61 notices that the subprocess has exited. */
62 extern void register_slave_subprocess (pid_t child
);
70 #endif /* _WAIT_PROCESS_H */