packaging: add --disable-experimental-malloc
[platform/upstream/glibc.git] / support / subprocess.h
1 /* Create a subprocess.
2    Copyright (C) 2019-2023 Free Software Foundation, Inc.
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
17    <https://www.gnu.org/licenses/>.  */
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 /* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it
42    to complete.  Return program exit status.  */
43 int support_subprogram_wait
44   (const char *file, char *const argv[]);
45
46 /* Wait for the subprocess indicated by PROC::PID.  Return the status
47    indicate by waitpid call.  */
48 int support_process_wait (struct support_subprocess *proc);
49
50 /* Terminate the subprocess indicated by PROC::PID, first with a SIGTERM and
51    then with a SIGKILL.  Return the status as for waitpid call.  */
52 int support_process_terminate (struct support_subprocess *proc);
53
54 #endif