sysvipc: Fix tst-sysvshm-linux on x32
[glibc.git] / support / subprocess.h
blob8b442fd5c0a2ecd5ed1b2769c46f4472057ced27
1 /* Create a subprocess.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #ifndef SUPPORT_SUBPROCESS_H
20 #define SUPPORT_SUBPROCESS_H
22 #include <sys/types.h>
24 struct support_subprocess
26 int stdout_pipe[2];
27 int stderr_pipe[2];
28 pid_t pid;
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);
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[]);
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);
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);
49 #endif