1 /* Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
26 #if !defined(ATF_C_DETAIL_PROCESS_H)
27 #define ATF_C_DETAIL_PROCESS_H
29 #include <sys/types.h>
33 #include <atf-c/detail/fs.h>
34 #include <atf-c/detail/list.h>
35 #include <atf-c/error_fwd.h>
37 /* ---------------------------------------------------------------------
38 * The "atf_process_stream" type.
39 * --------------------------------------------------------------------- */
41 struct atf_process_stream {
44 /* Valid if m_type == connect. */
48 /* Valid if m_type == redirect_fd. */
51 /* Valid if m_type == redirect_path. */
52 const atf_fs_path_t *m_path;
54 typedef struct atf_process_stream atf_process_stream_t;
56 extern const int atf_process_stream_type_capture;
57 extern const int atf_process_stream_type_connect;
58 extern const int atf_process_stream_type_inherit;
59 extern const int atf_process_stream_type_redirect_fd;
60 extern const int atf_process_stream_type_redirect_path;
62 atf_error_t atf_process_stream_init_capture(atf_process_stream_t *);
63 atf_error_t atf_process_stream_init_connect(atf_process_stream_t *,
64 const int, const int);
65 atf_error_t atf_process_stream_init_inherit(atf_process_stream_t *);
66 atf_error_t atf_process_stream_init_redirect_fd(atf_process_stream_t *,
68 atf_error_t atf_process_stream_init_redirect_path(atf_process_stream_t *,
69 const atf_fs_path_t *);
70 void atf_process_stream_fini(atf_process_stream_t *);
72 int atf_process_stream_type(const atf_process_stream_t *);
74 /* ---------------------------------------------------------------------
75 * The "atf_process_status" type.
76 * --------------------------------------------------------------------- */
78 struct atf_process_status {
81 typedef struct atf_process_status atf_process_status_t;
83 void atf_process_status_fini(atf_process_status_t *);
85 bool atf_process_status_exited(const atf_process_status_t *);
86 int atf_process_status_exitstatus(const atf_process_status_t *);
87 bool atf_process_status_signaled(const atf_process_status_t *);
88 int atf_process_status_termsig(const atf_process_status_t *);
89 bool atf_process_status_coredump(const atf_process_status_t *);
91 /* ---------------------------------------------------------------------
92 * The "atf_process_child" type.
93 * --------------------------------------------------------------------- */
95 struct atf_process_child {
101 typedef struct atf_process_child atf_process_child_t;
103 atf_error_t atf_process_child_wait(atf_process_child_t *,
104 atf_process_status_t *);
105 pid_t atf_process_child_pid(const atf_process_child_t *);
106 int atf_process_child_stdout(atf_process_child_t *);
107 int atf_process_child_stderr(atf_process_child_t *);
109 /* ---------------------------------------------------------------------
111 * --------------------------------------------------------------------- */
113 atf_error_t atf_process_fork(atf_process_child_t *,
115 const atf_process_stream_t *,
116 const atf_process_stream_t *,
118 atf_error_t atf_process_exec_array(atf_process_status_t *,
119 const atf_fs_path_t *,
121 const atf_process_stream_t *,
122 const atf_process_stream_t *,
124 atf_error_t atf_process_exec_list(atf_process_status_t *,
125 const atf_fs_path_t *,
127 const atf_process_stream_t *,
128 const atf_process_stream_t *,
131 #endif /* !defined(ATF_C_DETAIL_PROCESS_H) */