annotate lib/wait-process.h @ 7040:e97a4de675a6

* stdio--.h (tmpfile): Make safer.
author Eric Blake <ebb9@byu.net>
date Sun, 23 Jul 2006 18:50:12 +0000
parents 14eb5491c867
children bbbbbf4cd1c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4802
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Waiting for a subprocess to finish.
6751
1b0092424a44 Include <unistd.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 5848
diff changeset
2 Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
4802
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
5848
a48fb0e98c8c *** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents: 4927
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
4802
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #ifndef _WAIT_PROCESS_H
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #define _WAIT_PROCESS_H
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 /* Get pid_t. */
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <stdlib.h>
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <unistd.h>
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <sys/types.h>
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <stdbool.h>
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #ifdef __cplusplus
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 extern "C" {
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #endif
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 /* Wait for a subprocess to finish. Return its exit code.
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 If it didn't terminate correctly, exit if exit_on_error is true, otherwise
6761
14eb5491c867 * lib/wait-process.c, lib/wait-process.h, lib/csharpcomp.c,
Derek R. Price <derek@ximbiot.com>
parents: 6759
diff changeset
37 return 127.
4927
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
38 Arguments:
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
39 - child is the pid of the subprocess.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
40 - progname is the name of the program executed by the subprocess, used for
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
41 error messages.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
42 - If ignore_sigpipe is true, consider a subprocess termination due to
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
43 SIGPIPE as equivalent to a success. This is suitable for processes whose
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
44 only purpose is to write to standard output. This flag can be safely set
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
45 to false when the process' standard output is known to go to DEV_NULL.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
46 - If null_stderr is true, the usual error message to stderr will be omitted.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
47 This is suitable when the subprocess does not fulfill an important task.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
48 - slave_process should be set to true if the process has been launched as a
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
49 slave process.
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
50 - If exit_on_error is true, any error will cause the main process to exit
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
51 with an error status. */
4802
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 extern int wait_subprocess (pid_t child, const char *progname,
4927
bc5f62830252 Update from gettext.
Bruno Haible <bruno@clisp.org>
parents: 4802
diff changeset
53 bool ignore_sigpipe, bool null_stderr,
4802
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 bool slave_process, bool exit_on_error);
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 /* Register a subprocess as being a slave process. This means that the
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 subprocess will be terminated when its creator receives a catchable fatal
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 signal or exits normally. Registration ends when wait_subprocess()
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 notices that the subprocess has exited. */
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 extern void register_slave_subprocess (pid_t child);
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 #ifdef __cplusplus
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 }
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 #endif
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67
16d77b789c30 New module 'wait-process'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 #endif /* _WAIT_PROCESS_H */