/src/gstreamer/subprojects/glib-2.86.3/glib/gspawn-private.h
Line | Count | Source |
1 | | /* gspawn.c - Process launching |
2 | | * |
3 | | * Copyright 2000 Red Hat, Inc. |
4 | | * g_execvpe implementation based on GNU libc execvp: |
5 | | * Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc. |
6 | | * |
7 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
8 | | * |
9 | | * This library is free software; you can redistribute it and/or |
10 | | * modify it under the terms of the GNU Lesser General Public |
11 | | * License as published by the Free Software Foundation; either |
12 | | * version 2.1 of the License, or (at your option) any later version. |
13 | | * |
14 | | * This library is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | | * Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with this library; if not, see <http://www.gnu.org/licenses/>. |
21 | | */ |
22 | | |
23 | | #include "config.h" |
24 | | |
25 | | #include <errno.h> |
26 | | |
27 | | #include "glibintl.h" |
28 | | #include "gspawn.h" |
29 | | |
30 | | /* Platform-specific implementation functions. */ |
31 | | gboolean g_spawn_sync_impl (const gchar *working_directory, |
32 | | gchar **argv, |
33 | | gchar **envp, |
34 | | GSpawnFlags flags, |
35 | | GSpawnChildSetupFunc child_setup, |
36 | | gpointer user_data, |
37 | | gchar **standard_output, |
38 | | gchar **standard_error, |
39 | | gint *wait_status, |
40 | | GError **error); |
41 | | gboolean g_spawn_async_with_pipes_and_fds_impl (const gchar *working_directory, |
42 | | const gchar * const *argv, |
43 | | const gchar * const *envp, |
44 | | GSpawnFlags flags, |
45 | | GSpawnChildSetupFunc child_setup, |
46 | | gpointer user_data, |
47 | | gint stdin_fd, |
48 | | gint stdout_fd, |
49 | | gint stderr_fd, |
50 | | const gint *source_fds, |
51 | | const gint *target_fds, |
52 | | gsize n_fds, |
53 | | GPid *child_pid_out, |
54 | | gint *stdin_pipe_out, |
55 | | gint *stdout_pipe_out, |
56 | | gint *stderr_pipe_out, |
57 | | GError **error); |
58 | | gboolean g_spawn_check_wait_status_impl (gint wait_status, |
59 | | GError **error); |
60 | | void g_spawn_close_pid_impl (GPid pid); |
61 | | |
62 | | static inline gint |
63 | | _g_spawn_exec_err_to_g_error (gint en) |
64 | 2 | { |
65 | 2 | switch (en) |
66 | 2 | { |
67 | 0 | #ifdef EACCES |
68 | 0 | case EACCES: |
69 | 0 | return G_SPAWN_ERROR_ACCES; |
70 | 0 | #endif |
71 | | |
72 | 0 | #ifdef EPERM |
73 | 0 | case EPERM: |
74 | 0 | return G_SPAWN_ERROR_PERM; |
75 | 0 | #endif |
76 | | |
77 | 0 | #ifdef E2BIG |
78 | 0 | case E2BIG: |
79 | 0 | return G_SPAWN_ERROR_TOO_BIG; |
80 | 0 | #endif |
81 | | |
82 | 0 | #ifdef ENOEXEC |
83 | 0 | case ENOEXEC: |
84 | 0 | return G_SPAWN_ERROR_NOEXEC; |
85 | 0 | #endif |
86 | | |
87 | 0 | #ifdef ENAMETOOLONG |
88 | 0 | case ENAMETOOLONG: |
89 | 0 | return G_SPAWN_ERROR_NAMETOOLONG; |
90 | 0 | #endif |
91 | | |
92 | 0 | #ifdef ENOENT |
93 | 2 | case ENOENT: |
94 | 2 | return G_SPAWN_ERROR_NOENT; |
95 | 0 | #endif |
96 | | |
97 | 0 | #ifdef ENOMEM |
98 | 0 | case ENOMEM: |
99 | 0 | return G_SPAWN_ERROR_NOMEM; |
100 | 0 | #endif |
101 | | |
102 | 0 | #ifdef ENOTDIR |
103 | 0 | case ENOTDIR: |
104 | 0 | return G_SPAWN_ERROR_NOTDIR; |
105 | 0 | #endif |
106 | | |
107 | 0 | #ifdef ELOOP |
108 | 0 | case ELOOP: |
109 | 0 | return G_SPAWN_ERROR_LOOP; |
110 | 0 | #endif |
111 | | |
112 | | #ifdef ETXTBUSY |
113 | | case ETXTBUSY: |
114 | | return G_SPAWN_ERROR_TXTBUSY; |
115 | | #endif |
116 | | |
117 | 0 | #ifdef EIO |
118 | 0 | case EIO: |
119 | 0 | return G_SPAWN_ERROR_IO; |
120 | 0 | #endif |
121 | | |
122 | 0 | #ifdef ENFILE |
123 | 0 | case ENFILE: |
124 | 0 | return G_SPAWN_ERROR_NFILE; |
125 | 0 | #endif |
126 | | |
127 | 0 | #ifdef EMFILE |
128 | 0 | case EMFILE: |
129 | 0 | return G_SPAWN_ERROR_MFILE; |
130 | 0 | #endif |
131 | | |
132 | 0 | #ifdef EINVAL |
133 | 0 | case EINVAL: |
134 | 0 | return G_SPAWN_ERROR_INVAL; |
135 | 0 | #endif |
136 | | |
137 | 0 | #ifdef EISDIR |
138 | 0 | case EISDIR: |
139 | 0 | return G_SPAWN_ERROR_ISDIR; |
140 | 0 | #endif |
141 | | |
142 | 0 | #ifdef ELIBBAD |
143 | 0 | case ELIBBAD: |
144 | 0 | return G_SPAWN_ERROR_LIBBAD; |
145 | 0 | #endif |
146 | | |
147 | 0 | default: |
148 | 0 | return G_SPAWN_ERROR_FAILED; |
149 | 2 | } |
150 | 2 | } Unexecuted instantiation: gspawn.c:_g_spawn_exec_err_to_g_error gspawn-posix.c:_g_spawn_exec_err_to_g_error Line | Count | Source | 64 | 2 | { | 65 | 2 | switch (en) | 66 | 2 | { | 67 | 0 | #ifdef EACCES | 68 | 0 | case EACCES: | 69 | 0 | return G_SPAWN_ERROR_ACCES; | 70 | 0 | #endif | 71 | | | 72 | 0 | #ifdef EPERM | 73 | 0 | case EPERM: | 74 | 0 | return G_SPAWN_ERROR_PERM; | 75 | 0 | #endif | 76 | | | 77 | 0 | #ifdef E2BIG | 78 | 0 | case E2BIG: | 79 | 0 | return G_SPAWN_ERROR_TOO_BIG; | 80 | 0 | #endif | 81 | | | 82 | 0 | #ifdef ENOEXEC | 83 | 0 | case ENOEXEC: | 84 | 0 | return G_SPAWN_ERROR_NOEXEC; | 85 | 0 | #endif | 86 | | | 87 | 0 | #ifdef ENAMETOOLONG | 88 | 0 | case ENAMETOOLONG: | 89 | 0 | return G_SPAWN_ERROR_NAMETOOLONG; | 90 | 0 | #endif | 91 | | | 92 | 0 | #ifdef ENOENT | 93 | 2 | case ENOENT: | 94 | 2 | return G_SPAWN_ERROR_NOENT; | 95 | 0 | #endif | 96 | | | 97 | 0 | #ifdef ENOMEM | 98 | 0 | case ENOMEM: | 99 | 0 | return G_SPAWN_ERROR_NOMEM; | 100 | 0 | #endif | 101 | | | 102 | 0 | #ifdef ENOTDIR | 103 | 0 | case ENOTDIR: | 104 | 0 | return G_SPAWN_ERROR_NOTDIR; | 105 | 0 | #endif | 106 | | | 107 | 0 | #ifdef ELOOP | 108 | 0 | case ELOOP: | 109 | 0 | return G_SPAWN_ERROR_LOOP; | 110 | 0 | #endif | 111 | | | 112 | | #ifdef ETXTBUSY | 113 | | case ETXTBUSY: | 114 | | return G_SPAWN_ERROR_TXTBUSY; | 115 | | #endif | 116 | | | 117 | 0 | #ifdef EIO | 118 | 0 | case EIO: | 119 | 0 | return G_SPAWN_ERROR_IO; | 120 | 0 | #endif | 121 | | | 122 | 0 | #ifdef ENFILE | 123 | 0 | case ENFILE: | 124 | 0 | return G_SPAWN_ERROR_NFILE; | 125 | 0 | #endif | 126 | | | 127 | 0 | #ifdef EMFILE | 128 | 0 | case EMFILE: | 129 | 0 | return G_SPAWN_ERROR_MFILE; | 130 | 0 | #endif | 131 | | | 132 | 0 | #ifdef EINVAL | 133 | 0 | case EINVAL: | 134 | 0 | return G_SPAWN_ERROR_INVAL; | 135 | 0 | #endif | 136 | | | 137 | 0 | #ifdef EISDIR | 138 | 0 | case EISDIR: | 139 | 0 | return G_SPAWN_ERROR_ISDIR; | 140 | 0 | #endif | 141 | | | 142 | 0 | #ifdef ELIBBAD | 143 | 0 | case ELIBBAD: | 144 | 0 | return G_SPAWN_ERROR_LIBBAD; | 145 | 0 | #endif | 146 | | | 147 | 0 | default: | 148 | 0 | return G_SPAWN_ERROR_FAILED; | 149 | 2 | } | 150 | 2 | } |
|
151 | | |
152 | | static inline gboolean |
153 | | _g_spawn_invalid_source_fd (gint fd, |
154 | | const gint *source_fds, |
155 | | gsize n_fds, |
156 | | GError **error) |
157 | 12 | { |
158 | 12 | gsize i; |
159 | | |
160 | 12 | for (i = 0; i < n_fds; i++) |
161 | 0 | if (fd == source_fds[i]) |
162 | 0 | { |
163 | 0 | g_set_error (error, |
164 | 0 | G_SPAWN_ERROR, |
165 | 0 | G_SPAWN_ERROR_INVAL, |
166 | 0 | _("Invalid source FDs argument")); |
167 | 0 | return TRUE; |
168 | 0 | } |
169 | | |
170 | 12 | return FALSE; |
171 | 12 | } Unexecuted instantiation: gspawn.c:_g_spawn_invalid_source_fd gspawn-posix.c:_g_spawn_invalid_source_fd Line | Count | Source | 157 | 12 | { | 158 | 12 | gsize i; | 159 | | | 160 | 12 | for (i = 0; i < n_fds; i++) | 161 | 0 | if (fd == source_fds[i]) | 162 | 0 | { | 163 | 0 | g_set_error (error, | 164 | 0 | G_SPAWN_ERROR, | 165 | 0 | G_SPAWN_ERROR_INVAL, | 166 | 0 | _("Invalid source FDs argument")); | 167 | 0 | return TRUE; | 168 | 0 | } | 169 | | | 170 | 12 | return FALSE; | 171 | 12 | } |
|