58
58
<div class="refsynopsisdiv" title="Synopsis">
59
59
<a name="glib-Spawning-Processes.synopsis"></a><h2>Synopsis</h2>
60
60
<pre class="synopsis">
61
62
#include <glib.h>
63
64
enum <a class="link" href="glib-Spawning-Processes.html#GSpawnError" title="enum GSpawnError">GSpawnError</a>;
64
#define <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR:CAPS" title="G_SPAWN_ERROR">G_SPAWN_ERROR</a>
65
#define <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR--CAPS" title="G_SPAWN_ERROR">G_SPAWN_ERROR</a>
65
66
enum <a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a>;
66
<span class="returnvalue">void</span> (<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">*GSpawnChildSetupFunc</a>) (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data);
67
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()">g_spawn_async_with_pipes</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
68
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
69
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
70
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
71
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
72
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
73
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="returnvalue">GPid</span></a> *child_pid,
74
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_input,
75
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_output,
76
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_error,
77
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
78
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()">g_spawn_async</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
79
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
80
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
81
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
82
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
83
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
84
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="returnvalue">GPid</span></a> *child_pid,
85
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
86
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()">g_spawn_sync</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
87
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
88
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
89
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
90
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
91
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
92
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_output,
93
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_error,
94
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *exit_status,
95
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
96
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-command-line-async" title="g_spawn_command_line_async ()">g_spawn_command_line_async</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *command_line,
97
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
98
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-command-line-sync" title="g_spawn_command_line_sync ()">g_spawn_command_line_sync</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *command_line,
99
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_output,
100
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_error,
101
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *exit_status,
102
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
103
<span class="returnvalue">void</span> <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()">g_spawn_close_pid</a> (<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="returnvalue">GPid</span></a> pid);
67
void (<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">*GSpawnChildSetupFunc</a>) (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data);
68
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()">g_spawn_async_with_pipes</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
69
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
70
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
71
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
72
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
73
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
74
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a> *child_pid,
75
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_input,
76
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_output,
77
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_error,
78
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
79
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()">g_spawn_async</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
80
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
81
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
82
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
83
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
84
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
85
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a> *child_pid,
86
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
87
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()">g_spawn_sync</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
88
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
89
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
90
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
91
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
92
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
93
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_output,
94
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_error,
95
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *exit_status,
96
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
97
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-command-line-async" title="g_spawn_command_line_async ()">g_spawn_command_line_async</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *command_line,
98
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
99
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-Spawning-Processes.html#g-spawn-command-line-sync" title="g_spawn_command_line_sync ()">g_spawn_command_line_sync</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *command_line,
100
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_output,
101
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_error,
102
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *exit_status,
103
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
104
void <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()">g_spawn_close_pid</a> (<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a> pid);
106
107
<div class="refsect1" title="Description">
145
146
<col align="left" valign="top">
148
<td><p><a name="G-SPAWN-ERROR-FORK:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_FORK</code></span></p></td>
149
<td><p><a name="G-SPAWN-ERROR-FORK--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_FORK</code></span></p></td>
149
150
<td>Fork failed due to lack of memory.
153
<td><p><a name="G-SPAWN-ERROR-READ:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_READ</code></span></p></td>
154
<td><p><a name="G-SPAWN-ERROR-READ--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_READ</code></span></p></td>
154
155
<td>Read or select on pipes failed.
158
<td><p><a name="G-SPAWN-ERROR-CHDIR:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_CHDIR</code></span></p></td>
159
<td><p><a name="G-SPAWN-ERROR-CHDIR--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_CHDIR</code></span></p></td>
159
160
<td>Changing to working directory failed.
163
<td><p><a name="G-SPAWN-ERROR-ACCES:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_ACCES</code></span></p></td>
164
<td>execv() returned <code class="literal">EACCES</code>.
168
<td><p><a name="G-SPAWN-ERROR-PERM:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_PERM</code></span></p></td>
169
<td>execv() returned <code class="literal">EPERM</code>.
173
<td><p><a name="G-SPAWN-ERROR-2BIG:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_2BIG</code></span></p></td>
174
<td>execv() returned <code class="literal">E2BIG</code>.
178
<td><p><a name="G-SPAWN-ERROR-NOEXEC:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOEXEC</code></span></p></td>
179
<td>execv() returned <code class="literal">ENOEXEC</code>.
183
<td><p><a name="G-SPAWN-ERROR-NAMETOOLONG:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NAMETOOLONG</code></span></p></td>
184
<td>execv() returned <code class="literal">ENAMETOOLONG</code>.
188
<td><p><a name="G-SPAWN-ERROR-NOENT:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOENT</code></span></p></td>
189
<td>execv() returned <code class="literal">ENOENT</code>.
193
<td><p><a name="G-SPAWN-ERROR-NOMEM:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOMEM</code></span></p></td>
194
<td>execv() returned <code class="literal">ENOMEM</code>.
198
<td><p><a name="G-SPAWN-ERROR-NOTDIR:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOTDIR</code></span></p></td>
199
<td>execv() returned <code class="literal">ENOTDIR</code>.
203
<td><p><a name="G-SPAWN-ERROR-LOOP:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_LOOP</code></span></p></td>
204
<td>execv() returned <code class="literal">ELOOP</code>.
208
<td><p><a name="G-SPAWN-ERROR-TXTBUSY:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_TXTBUSY</code></span></p></td>
209
<td>execv() returned <code class="literal">ETXTBUSY</code>.
213
<td><p><a name="G-SPAWN-ERROR-IO:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_IO</code></span></p></td>
214
<td>execv() returned <code class="literal">EIO</code>.
218
<td><p><a name="G-SPAWN-ERROR-NFILE:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NFILE</code></span></p></td>
219
<td>execv() returned <code class="literal">ENFILE</code>.
223
<td><p><a name="G-SPAWN-ERROR-MFILE:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_MFILE</code></span></p></td>
224
<td>execv() returned <code class="literal">EMFILE</code>.
228
<td><p><a name="G-SPAWN-ERROR-INVAL:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_INVAL</code></span></p></td>
229
<td>execv() returned <code class="literal">EINVAL</code>.
233
<td><p><a name="G-SPAWN-ERROR-ISDIR:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_ISDIR</code></span></p></td>
234
<td>execv() returned <code class="literal">EISDIR</code>.
238
<td><p><a name="G-SPAWN-ERROR-LIBBAD:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_LIBBAD</code></span></p></td>
239
<td>execv() returned <code class="literal">ELIBBAD</code>.
243
<td><p><a name="G-SPAWN-ERROR-FAILED:CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_FAILED</code></span></p></td>
164
<td><p><a name="G-SPAWN-ERROR-ACCES--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_ACCES</code></span></p></td>
166
<code class="function">execv()</code> returned <code class="literal">EACCES</code>.
170
<td><p><a name="G-SPAWN-ERROR-PERM--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_PERM</code></span></p></td>
172
<code class="function">execv()</code> returned <code class="literal">EPERM</code>.
176
<td><p><a name="G-SPAWN-ERROR-2BIG--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_2BIG</code></span></p></td>
178
<code class="function">execv()</code> returned <code class="literal">E2BIG</code>.
182
<td><p><a name="G-SPAWN-ERROR-NOEXEC--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOEXEC</code></span></p></td>
184
<code class="function">execv()</code> returned <code class="literal">ENOEXEC</code>.
188
<td><p><a name="G-SPAWN-ERROR-NAMETOOLONG--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NAMETOOLONG</code></span></p></td>
190
<code class="function">execv()</code> returned <code class="literal">ENAMETOOLONG</code>.
194
<td><p><a name="G-SPAWN-ERROR-NOENT--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOENT</code></span></p></td>
196
<code class="function">execv()</code> returned <code class="literal">ENOENT</code>.
200
<td><p><a name="G-SPAWN-ERROR-NOMEM--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOMEM</code></span></p></td>
202
<code class="function">execv()</code> returned <code class="literal">ENOMEM</code>.
206
<td><p><a name="G-SPAWN-ERROR-NOTDIR--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NOTDIR</code></span></p></td>
208
<code class="function">execv()</code> returned <code class="literal">ENOTDIR</code>.
212
<td><p><a name="G-SPAWN-ERROR-LOOP--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_LOOP</code></span></p></td>
214
<code class="function">execv()</code> returned <code class="literal">ELOOP</code>.
218
<td><p><a name="G-SPAWN-ERROR-TXTBUSY--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_TXTBUSY</code></span></p></td>
220
<code class="function">execv()</code> returned <code class="literal">ETXTBUSY</code>.
224
<td><p><a name="G-SPAWN-ERROR-IO--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_IO</code></span></p></td>
226
<code class="function">execv()</code> returned <code class="literal">EIO</code>.
230
<td><p><a name="G-SPAWN-ERROR-NFILE--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_NFILE</code></span></p></td>
232
<code class="function">execv()</code> returned <code class="literal">ENFILE</code>.
236
<td><p><a name="G-SPAWN-ERROR-MFILE--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_MFILE</code></span></p></td>
238
<code class="function">execv()</code> returned <code class="literal">EMFILE</code>.
242
<td><p><a name="G-SPAWN-ERROR-INVAL--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_INVAL</code></span></p></td>
244
<code class="function">execv()</code> returned <code class="literal">EINVAL</code>.
248
<td><p><a name="G-SPAWN-ERROR-ISDIR--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_ISDIR</code></span></p></td>
250
<code class="function">execv()</code> returned <code class="literal">EISDIR</code>.
254
<td><p><a name="G-SPAWN-ERROR-LIBBAD--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_LIBBAD</code></span></p></td>
256
<code class="function">execv()</code> returned <code class="literal">ELIBBAD</code>.
260
<td><p><a name="G-SPAWN-ERROR-FAILED--CAPS"></a><span class="term"><code class="literal">G_SPAWN_ERROR_FAILED</code></span></p></td>
244
261
<td>Some other fatal failure, <code class="literal">error->message</code> should explain.
280
298
<col align="left" valign="top">
283
<td><p><a name="G-SPAWN-LEAVE-DESCRIPTORS-OPEN:CAPS"></a><span class="term"><code class="literal">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></span></p></td>
301
<td><p><a name="G-SPAWN-LEAVE-DESCRIPTORS-OPEN--CAPS"></a><span class="term"><code class="literal">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></span></p></td>
284
302
<td>the parent's open file descriptors will be
285
303
inherited by the child; otherwise all descriptors except stdin/stdout/stderr
286
304
will be closed before calling <code class="function">exec()</code> in the child.
290
<td><p><a name="G-SPAWN-DO-NOT-REAP-CHILD:CAPS"></a><span class="term"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></span></p></td>
308
<td><p><a name="G-SPAWN-DO-NOT-REAP-CHILD--CAPS"></a><span class="term"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></span></p></td>
291
309
<td>the child will not be automatically reaped; you
292
310
must use <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a> yourself (or call <code class="function">waitpid()</code>
293
311
or handle <code class="literal">SIGCHLD</code> yourself), or the child will become a zombie.
297
<td><p><a name="G-SPAWN-SEARCH-PATH:CAPS"></a><span class="term"><code class="literal">G_SPAWN_SEARCH_PATH</code></span></p></td>
315
<td><p><a name="G-SPAWN-SEARCH-PATH--CAPS"></a><span class="term"><code class="literal">G_SPAWN_SEARCH_PATH</code></span></p></td>
299
317
<code class="literal">argv[0]</code> need not be an absolute path,
300
318
it will be looked for in the user's <code class="envar">PATH</code>.
304
<td><p><a name="G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"></a><span class="term"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></span></p></td>
322
<td><p><a name="G-SPAWN-STDOUT-TO-DEV-NULL--CAPS"></a><span class="term"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></span></p></td>
305
323
<td>the child's standard output will be discarded,
306
324
instead of going to the same location as the parent's standard output.
310
<td><p><a name="G-SPAWN-STDERR-TO-DEV-NULL:CAPS"></a><span class="term"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></span></p></td>
328
<td><p><a name="G-SPAWN-STDERR-TO-DEV-NULL--CAPS"></a><span class="term"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></span></p></td>
311
329
<td>the child's standard error will be discarded.
315
<td><p><a name="G-SPAWN-CHILD-INHERITS-STDIN:CAPS"></a><span class="term"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></span></p></td>
333
<td><p><a name="G-SPAWN-CHILD-INHERITS-STDIN--CAPS"></a><span class="term"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></span></p></td>
316
334
<td>the child will inherit the parent's standard
317
335
input (by default, the child's standard input is attached to
318
336
<code class="filename">/dev/null</code>).
322
<td><p><a name="G-SPAWN-FILE-AND-ARGV-ZERO:CAPS"></a><span class="term"><code class="literal">G_SPAWN_FILE_AND_ARGV_ZERO</code></span></p></td>
340
<td><p><a name="G-SPAWN-FILE-AND-ARGV-ZERO--CAPS"></a><span class="term"><code class="literal">G_SPAWN_FILE_AND_ARGV_ZERO</code></span></p></td>
323
341
<td>the first element of <code class="literal">argv</code> is
324
342
the file to execute, while the remaining elements are the actual argument
325
343
vector to pass to the file. Normally <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> uses
371
389
<div class="refsect2" title="g_spawn_async_with_pipes ()">
372
390
<a name="g-spawn-async-with-pipes"></a><h3>g_spawn_async_with_pipes ()</h3>
373
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_spawn_async_with_pipes (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
374
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
375
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
376
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
377
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
378
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
379
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="returnvalue">GPid</span></a> *child_pid,
380
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_input,
381
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_output,
382
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *standard_error,
383
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
391
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_spawn_async_with_pipes (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
392
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
393
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
394
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
395
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
396
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
397
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a> *child_pid,
398
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_input,
399
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_output,
400
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *standard_error,
401
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
385
403
Executes a child program asynchronously (your program will not
386
404
block waiting for the child to exit). The child program is
387
405
specified by the only argument that must be provided, <em class="parameter"><code>argv</code></em>. <em class="parameter"><code>argv</code></em>
388
should be a <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated array of strings, to be passed as the
406
should be a <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated array of strings, to be passed as the
389
407
argument vector for the child. The first string in <em class="parameter"><code>argv</code></em> is of
390
408
course the name of the program to execute. By default, the name of
391
409
the program must be a full path; the <code class="envar">PATH</code> shell variable
392
will only be searched if you pass the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag.
410
will only be searched if you pass the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag.
395
413
On Windows, note that all the string or string vector arguments to
454
472
<em class="parameter"><code>child_pid</code></em>).
457
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-LEAVE-DESCRIPTORS-OPEN:CAPS"><code class="literal">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></a> means that the parent's open file
475
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-LEAVE-DESCRIPTORS-OPEN--CAPS"><code class="literal">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></a> means that the parent's open file
458
476
descriptors will be inherited by the child; otherwise all
459
477
descriptors except stdin/stdout/stderr will be closed before
460
calling <code class="function">exec()</code> in the child. <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a>
478
calling <code class="function">exec()</code> in the child. <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a>
461
479
means that <code class="literal">argv[0]</code> need not be an absolute path, it
462
480
will be looked for in the user's <code class="envar">PATH</code>.
463
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a> means that the child's standard output will
481
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a> means that the child's standard output will
464
482
be discarded, instead of going to the same location as the parent's
465
standard output. If you use this flag, <em class="parameter"><code>standard_output</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
466
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a> means that the child's standard error
483
standard output. If you use this flag, <em class="parameter"><code>standard_output</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
484
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a> means that the child's standard error
467
485
will be discarded, instead of going to the same location as the parent's
468
standard error. If you use this flag, <em class="parameter"><code>standard_error</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
469
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-CHILD-INHERITS-STDIN:CAPS"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></a> means that the child will inherit the parent's
486
standard error. If you use this flag, <em class="parameter"><code>standard_error</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
487
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-CHILD-INHERITS-STDIN--CAPS"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></a> means that the child will inherit the parent's
470
488
standard input (by default, the child's standard input is attached to
471
/dev/null). If you use this flag, <em class="parameter"><code>standard_input</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
472
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-FILE-AND-ARGV-ZERO:CAPS"><code class="literal">G_SPAWN_FILE_AND_ARGV_ZERO</code></a> means that the first element of <em class="parameter"><code>argv</code></em> is
489
/dev/null). If you use this flag, <em class="parameter"><code>standard_input</code></em> must be <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
490
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-FILE-AND-ARGV-ZERO--CAPS"><code class="literal">G_SPAWN_FILE_AND_ARGV_ZERO</code></a> means that the first element of <em class="parameter"><code>argv</code></em> is
473
491
the file to execute, while the remaining elements are the
474
492
actual argument vector to pass to the file. Normally
475
493
<a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> uses <em class="parameter"><code>argv</code></em>[0] as the file to execute, and
492
510
could be used for on Windows so it is ignored and not called.
495
If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, <em class="parameter"><code>child_pid</code></em> will on Unix be filled with the child's
513
If non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, <em class="parameter"><code>child_pid</code></em> will on Unix be filled with the child's
496
514
process ID. You can use the process ID to send signals to the
497
515
child, or to use <a class="link" href="glib-The-Main-Event-Loop.html#g-child-watch-add" title="g_child_watch_add ()"><code class="function">g_child_watch_add()</code></a> (or <code class="function">waitpid()</code>) if you specified the
498
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag. On Windows, <em class="parameter"><code>child_pid</code></em> will be
516
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD--CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag. On Windows, <em class="parameter"><code>child_pid</code></em> will be
499
517
filled with a handle to the child process only if you specified the
500
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag. You can then access the child
518
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD--CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag. You can then access the child
501
519
process using the Win32 API, for example wait for its termination
502
520
with the <code class="function">WaitFor*()</code> functions, or examine its
503
521
exit code with <code class="function">GetExitCodeProcess()</code>. You should close the handle
504
522
with <code class="function">CloseHandle()</code> or <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a> when you no longer need it.
507
If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the <em class="parameter"><code>standard_input</code></em>, <em class="parameter"><code>standard_output</code></em>, <em class="parameter"><code>standard_error</code></em>
525
If non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, the <em class="parameter"><code>standard_input</code></em>, <em class="parameter"><code>standard_output</code></em>, <em class="parameter"><code>standard_error</code></em>
508
526
locations will be filled with file descriptors for writing to the child's
509
527
standard input or reading from its standard output or standard error.
510
528
The caller of <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> must close these file descriptors
511
when they are no longer in use. If these parameters are <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the corresponding
529
when they are no longer in use. If these parameters are <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, the corresponding
512
530
pipe won't be created.
515
533
If <em class="parameter"><code>standard_input</code></em> is NULL, the child's standard input is attached to
516
/dev/null unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-CHILD-INHERITS-STDIN:CAPS"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></a> is set.
534
/dev/null unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-CHILD-INHERITS-STDIN--CAPS"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></a> is set.
519
537
If <em class="parameter"><code>standard_error</code></em> is NULL, the child's standard error goes to the same
520
location as the parent's standard error unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a>
538
location as the parent's standard error unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a>
524
542
If <em class="parameter"><code>standard_output</code></em> is NULL, the child's standard output goes to the same
525
location as the parent's standard output unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a>
543
location as the parent's standard output unless <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a>
529
<em class="parameter"><code>error</code></em> can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore errors, or non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to report errors.
530
If an error is set, the function returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>. Errors
547
<em class="parameter"><code>error</code></em> can be <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> to ignore errors, or non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> to report errors.
548
If an error is set, the function returns <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a>. Errors
531
549
are reported even if they occur in the child (for example if the
532
550
executable in <code class="literal">argv[0]</code> is not found). Typically
533
551
the <code class="literal">message</code> field of returned errors should be displayed
534
to users. Possible errors are those from the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR:CAPS" title="G_SPAWN_ERROR"><span class="type">G_SPAWN_ERROR</span></a> domain.
552
to users. Possible errors are those from the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-ERROR--CAPS" title="G_SPAWN_ERROR"><span class="type">G_SPAWN_ERROR</span></a> domain.
537
555
If an error occurs, <em class="parameter"><code>child_pid</code></em>, <em class="parameter"><code>standard_input</code></em>, <em class="parameter"><code>standard_output</code></em>,
538
556
and <em class="parameter"><code>standard_error</code></em> will not be filled with valid values.
541
If <em class="parameter"><code>child_pid</code></em> is not <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> and an error does not occur then the returned
559
If <em class="parameter"><code>child_pid</code></em> is not <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> and an error does not occur then the returned
542
560
process reference must be closed using <a class="link" href="glib-Spawning-Processes.html#g-spawn-close-pid" title="g_spawn_close_pid ()"><code class="function">g_spawn_close_pid()</code></a>.
622
642
<div class="refsect2" title="g_spawn_async ()">
623
643
<a name="g-spawn-async"></a><h3>g_spawn_async ()</h3>
624
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_spawn_async (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
625
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
626
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
627
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
628
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
629
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
630
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid"><span class="returnvalue">GPid</span></a> *child_pid,
631
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
644
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_spawn_async (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
645
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
646
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
647
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
648
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
649
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
650
<a class="link" href="glib-The-Main-Event-Loop.html#GPid" title="GPid">GPid</a> *child_pid,
651
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
633
653
See <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> for a full description; this function
634
654
simply calls the <a class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes" title="g_spawn_async_with_pipes ()"><code class="function">g_spawn_async_with_pipes()</code></a> without any pipes.
714
736
<div class="refsect2" title="g_spawn_sync ()">
715
737
<a name="g-spawn-sync"></a><h3>g_spawn_sync ()</h3>
716
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_spawn_sync (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *working_directory,
717
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **argv,
718
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **envp,
719
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags"><span class="returnvalue">GSpawnFlags</span></a> flags,
720
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()"><span class="returnvalue">GSpawnChildSetupFunc</span></a> child_setup,
721
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a> user_data,
722
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_output,
723
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_error,
724
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *exit_status,
725
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
738
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_spawn_sync (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *working_directory,
739
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **argv,
740
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **envp,
741
<a class="link" href="glib-Spawning-Processes.html#GSpawnFlags" title="enum GSpawnFlags">GSpawnFlags</a> flags,
742
<a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc" title="GSpawnChildSetupFunc ()">GSpawnChildSetupFunc</a> child_setup,
743
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data,
744
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_output,
745
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_error,
746
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *exit_status,
747
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
727
749
Executes a child synchronously (waits for the child to exit before returning).
728
750
All output from the child is stored in <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>,
729
if those parameters are non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. Note that you must set the
730
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a> and <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a> flags when
731
passing <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>.
732
If <em class="parameter"><code>exit_status</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the exit status of the child is stored
751
if those parameters are non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>. Note that you must set the
752
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a> and <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL--CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a> flags when
753
passing <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> for <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>.
754
If <em class="parameter"><code>exit_status</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, the exit status of the child is stored
733
755
there as it would be returned by <code class="function">waitpid()</code>; standard UNIX macros such
734
756
as <code class="function">WIFEXITED()</code> and <code class="function">WEXITSTATUS()</code> must be used to evaluate the exit status.
735
Note that this function call <code class="function">waitpid()</code> even if <em class="parameter"><code>exit_status</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, and
736
does not accept the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag.
757
Note that this function call <code class="function">waitpid()</code> even if <em class="parameter"><code>exit_status</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, and
758
does not accept the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD--CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> flag.
737
759
If an error occurs, no data is returned in <em class="parameter"><code>standard_output</code></em>,
738
760
<em class="parameter"><code>standard_error</code></em>, or <em class="parameter"><code>exit_status</code></em>.
778
802
<td><p><span class="term"><em class="parameter"><code>standard_output</code></em> :</span></p></td>
779
<td> return location for child output, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
803
<td> return location for child output, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
783
807
<td><p><span class="term"><em class="parameter"><code>standard_error</code></em> :</span></p></td>
784
<td> return location for child error messages, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
808
<td> return location for child error messages, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
788
812
<td><p><span class="term"><em class="parameter"><code>exit_status</code></em> :</span></p></td>
789
<td> return location for child exit status, as returned by <code class="function">waitpid()</code>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
813
<td> return location for child exit status, as returned by <code class="function">waitpid()</code>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
793
817
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
794
<td> return location for error, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
818
<td> return location for error, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
798
822
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
799
<td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if an error was set.
823
<td> <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> if an error was set.
806
830
<div class="refsect2" title="g_spawn_command_line_async ()">
807
831
<a name="g-spawn-command-line-async"></a><h3>g_spawn_command_line_async ()</h3>
808
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_spawn_command_line_async (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *command_line,
809
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
832
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_spawn_command_line_async (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *command_line,
833
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
811
835
A simple version of <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> that parses a command line with
812
836
<a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv" title="g_shell_parse_argv ()"><code class="function">g_shell_parse_argv()</code></a> and passes it to <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a>. Runs a
813
837
command line in the background. Unlike <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a>, the
814
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag is enabled, other flags are not. Note
815
that <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security implications, so
838
<a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag is enabled, other flags are not. Note
839
that <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security implications, so
816
840
consider using <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a> directly if appropriate. Possible
817
841
errors are those from <a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv" title="g_shell_parse_argv ()"><code class="function">g_shell_parse_argv()</code></a> and <a class="link" href="glib-Spawning-Processes.html#g-spawn-async" title="g_spawn_async ()"><code class="function">g_spawn_async()</code></a>.
820
844
The same concerns on Windows apply as for <a class="link" href="glib-Spawning-Processes.html#g-spawn-command-line-sync" title="g_spawn_command_line_sync ()"><code class="function">g_spawn_command_line_sync()</code></a>.</p>
821
847
<div class="variablelist"><table border="0">
822
848
<col align="left" valign="top">
843
869
<div class="refsect2" title="g_spawn_command_line_sync ()">
844
870
<a name="g-spawn-command-line-sync"></a><h3>g_spawn_command_line_sync ()</h3>
845
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_spawn_command_line_sync (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *command_line,
846
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_output,
847
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **standard_error,
848
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> *exit_status,
849
<a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
871
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_spawn_command_line_sync (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *command_line,
872
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_output,
873
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **standard_error,
874
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> *exit_status,
875
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
851
877
A simple version of <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a> with little-used parameters
852
878
removed, taking a command line instead of an argument vector. See
853
879
<a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a> for full details. <em class="parameter"><code>command_line</code></em> will be parsed by
854
<a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv" title="g_shell_parse_argv ()"><code class="function">g_shell_parse_argv()</code></a>. Unlike <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a>, the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag
855
is enabled. Note that <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security
880
<a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv" title="g_shell_parse_argv ()"><code class="function">g_shell_parse_argv()</code></a>. Unlike <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a>, the <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag
881
is enabled. Note that <a class="link" href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH--CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security
856
882
implications, so consider using <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a> directly if
857
883
appropriate. Possible errors are those from <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync" title="g_spawn_sync ()"><code class="function">g_spawn_sync()</code></a> and those
858
884
from <a class="link" href="glib-Shell-related-Utilities.html#g-shell-parse-argv" title="g_shell_parse_argv ()"><code class="function">g_shell_parse_argv()</code></a>.
861
If <em class="parameter"><code>exit_status</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, the exit status of the child is stored there as
887
If <em class="parameter"><code>exit_status</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, the exit status of the child is stored there as
862
888
it would be returned by <code class="function">waitpid()</code>; standard UNIX macros such as <code class="function">WIFEXITED()</code>
863
889
and <code class="function">WEXITSTATUS()</code> must be used to evaluate the exit status.