]>
Commit | Line | Data |
---|---|---|
0e169691 | 1 | /* Create a subprocess. |
d614a753 | 2 | Copyright (C) 2019-2020 Free Software Foundation, Inc. |
0e169691 AZ |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library 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 GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
0e169691 AZ |
18 | |
19 | #ifndef SUPPORT_SUBPROCESS_H | |
20 | #define SUPPORT_SUBPROCESS_H | |
21 | ||
22 | #include <sys/types.h> | |
23 | ||
24 | struct support_subprocess | |
25 | { | |
26 | int stdout_pipe[2]; | |
27 | int stderr_pipe[2]; | |
28 | pid_t pid; | |
29 | }; | |
30 | ||
31 | /* Invoke CALLBACK (CLOSURE) in a subprocess created with fork and return | |
32 | its PID, a pipe redirected to STDOUT, and a pipe redirected to STDERR. */ | |
33 | struct support_subprocess support_subprocess | |
34 | (void (*callback) (void *), void *closure); | |
35 | ||
36 | /* Issue FILE with ARGV arguments by using posix_spawn and return is PID, a | |
37 | pipe redirected to STDOUT, and a pipe redirected to STDERR. */ | |
38 | struct support_subprocess support_subprogram | |
39 | (const char *file, char *const argv[]); | |
40 | ||
41 | /* Wait for the subprocess indicated by PROC::PID. Return the status | |
42 | indicate by waitpid call. */ | |
43 | int support_process_wait (struct support_subprocess *proc); | |
44 | ||
45 | /* Terminate the subprocess indicated by PROC::PID, first with a SIGTERM and | |
46 | then with a SIGKILL. Return the status as for waitpid call. */ | |
47 | int support_process_terminate (struct support_subprocess *proc); | |
48 | ||
49 | #endif |