KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/share/gtk-doc/html/glib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/gtk-doc/html/glib/glib-Spawning-Processes.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Spawning Processes</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Timers.html" title="Timers">
<link rel="next" href="glib-File-Utilities.html" title="File Utilities">
<meta name="generator" content="GTK-Doc V1.6 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Timers.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-File-Utilities.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3101766" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id3102233" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Spawning-Processes"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3101766"></a><span class="refentrytitle">Spawning Processes</span>
</h2>
<p>Spawning Processes &#8212; process launching with <code class="function"><code class="function">fork()</code></code>/<code class="function"><code class="function">exec()</code></code>.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


enum        <a href="glib-Spawning-Processes.html#GSpawnError">GSpawnError</a>;
#define     <a href="glib-Spawning-Processes.html#G-SPAWN-ERROR:CAPS">G_SPAWN_ERROR</a>
enum        <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a>;
void        (<a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">*GSpawnChildSetupFunc</a>)         (<a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes">g_spawn_async_with_pipes</a>        (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> *child_pid,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_input,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_output,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_error,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Spawning-Processes.html#g-spawn-async">g_spawn_async</a>                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> *child_pid,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Spawning-Processes.html#g-spawn-sync">g_spawn_sync</a>                    (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *exit_status,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Spawning-Processes.html#g-spawn-command-line-async">g_spawn_command_line_async</a>      (const <a href="glib-Basic-Types.html#gchar">gchar</a> *command_line,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Spawning-Processes.html#g-spawn-command-line-sync">g_spawn_command_line_sync</a>       (const <a href="glib-Basic-Types.html#gchar">gchar</a> *command_line,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *exit_status,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);
void        <a href="glib-Spawning-Processes.html#g-spawn-close-pid">g_spawn_close_pid</a>               (<a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> pid);

</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3102233"></a><h2>Description</h2>
<p>

</p>
</div>
<div class="refsect1" lang="en">
<a name="id3102247"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3102257"></a><h3>
<a name="GSpawnError"></a>enum GSpawnError</h3>
<a class="indexterm" name="id3102270"></a><pre class="programlisting">typedef enum
{
  G_SPAWN_ERROR_FORK,   /* fork failed due to lack of memory */
  G_SPAWN_ERROR_READ,   /* read or select on pipes failed */
  G_SPAWN_ERROR_CHDIR,  /* changing to working dir failed */
  G_SPAWN_ERROR_ACCES,  /* execv() returned EACCES */
  G_SPAWN_ERROR_PERM,   /* execv() returned EPERM */
  G_SPAWN_ERROR_2BIG,   /* execv() returned E2BIG */
  G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */
  G_SPAWN_ERROR_NAMETOOLONG, /* ""  "" ENAMETOOLONG */
  G_SPAWN_ERROR_NOENT,       /* ""  "" ENOENT */
  G_SPAWN_ERROR_NOMEM,       /* ""  "" ENOMEM */
  G_SPAWN_ERROR_NOTDIR,      /* ""  "" ENOTDIR */
  G_SPAWN_ERROR_LOOP,        /* ""  "" ELOOP   */
  G_SPAWN_ERROR_TXTBUSY,     /* ""  "" ETXTBUSY */
  G_SPAWN_ERROR_IO,          /* ""  "" EIO */
  G_SPAWN_ERROR_NFILE,       /* ""  "" ENFILE */
  G_SPAWN_ERROR_MFILE,       /* ""  "" EMFLE */
  G_SPAWN_ERROR_INVAL,       /* ""  "" EINVAL */
  G_SPAWN_ERROR_ISDIR,       /* ""  "" EISDIR */
  G_SPAWN_ERROR_LIBBAD,      /* ""  "" ELIBBAD */
  G_SPAWN_ERROR_FAILED       /* other fatal failure, error-&gt;message
                              * should explain
                              */
} GSpawnError;
</pre>
<p>
Error codes returned by spawning processes.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-FORK:CAPS"></a><code class="literal">G_SPAWN_ERROR_FORK</code></span></td>
<td>Fork failed due to lack of memory.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-READ:CAPS"></a><code class="literal">G_SPAWN_ERROR_READ</code></span></td>
<td>Read or select on pipes failed.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-CHDIR:CAPS"></a><code class="literal">G_SPAWN_ERROR_CHDIR</code></span></td>
<td>Changing to working directory failed.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-ACCES:CAPS"></a><code class="literal">G_SPAWN_ERROR_ACCES</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EACCES</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-PERM:CAPS"></a><code class="literal">G_SPAWN_ERROR_PERM</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EPERM</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-2BIG:CAPS"></a><code class="literal">G_SPAWN_ERROR_2BIG</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">E2BIG</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NOEXEC:CAPS"></a><code class="literal">G_SPAWN_ERROR_NOEXEC</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENOEXEC</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NAMETOOLONG:CAPS"></a><code class="literal">G_SPAWN_ERROR_NAMETOOLONG</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENAMETOOLONG</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NOENT:CAPS"></a><code class="literal">G_SPAWN_ERROR_NOENT</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENOENT</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NOMEM:CAPS"></a><code class="literal">G_SPAWN_ERROR_NOMEM</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENOMEM</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NOTDIR:CAPS"></a><code class="literal">G_SPAWN_ERROR_NOTDIR</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENOTDIR</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-LOOP:CAPS"></a><code class="literal">G_SPAWN_ERROR_LOOP</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ELOOP</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-TXTBUSY:CAPS"></a><code class="literal">G_SPAWN_ERROR_TXTBUSY</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ETXTBUSY</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-IO:CAPS"></a><code class="literal">G_SPAWN_ERROR_IO</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EIO</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-NFILE:CAPS"></a><code class="literal">G_SPAWN_ERROR_NFILE</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ENFILE</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-MFILE:CAPS"></a><code class="literal">G_SPAWN_ERROR_MFILE</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EMFILE</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-INVAL:CAPS"></a><code class="literal">G_SPAWN_ERROR_INVAL</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EINVAL</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-ISDIR:CAPS"></a><code class="literal">G_SPAWN_ERROR_ISDIR</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">EISDIR</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-LIBBAD:CAPS"></a><code class="literal">G_SPAWN_ERROR_LIBBAD</code></span></td>
<td>
<code class="function"><code class="function">execv()</code></code> returned <code class="literal">ELIBBAD</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-ERROR-FAILED:CAPS"></a><code class="literal">G_SPAWN_ERROR_FAILED</code></span></td>
<td>Some other fatal failure, <code class="literal">error-&gt;message</code> should explain.

</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3103166"></a><h3>
<a name="G-SPAWN-ERROR:CAPS"></a>G_SPAWN_ERROR</h3>
<a class="indexterm" name="id3103179"></a><pre class="programlisting">#define G_SPAWN_ERROR g_spawn_error_quark ()
</pre>
<p>
Error domain for spawning processes. Errors in this domain will
be from the <a href="glib-Spawning-Processes.html#GSpawnError"><span class="type">GSpawnError</span></a> enumeration. See <a href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for information on
error domains.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3103212"></a><h3>
<a name="GSpawnFlags"></a>enum GSpawnFlags</h3>
<a class="indexterm" name="id3103225"></a><pre class="programlisting">typedef enum
{
  G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 &lt;&lt; 0,
  G_SPAWN_DO_NOT_REAP_CHILD      = 1 &lt;&lt; 1,
  /* look for argv[0] in the path i.e. use execvp() */
  G_SPAWN_SEARCH_PATH            = 1 &lt;&lt; 2,
  /* Dump output to /dev/null */
  G_SPAWN_STDOUT_TO_DEV_NULL     = 1 &lt;&lt; 3,
  G_SPAWN_STDERR_TO_DEV_NULL     = 1 &lt;&lt; 4,
  G_SPAWN_CHILD_INHERITS_STDIN   = 1 &lt;&lt; 5,
  G_SPAWN_FILE_AND_ARGV_ZERO     = 1 &lt;&lt; 6
} GSpawnFlags;
</pre>
<p>
Flags passed to <a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a>, <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a> and <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><a name="G-SPAWN-LEAVE-DESCRIPTORS-OPEN:CAPS"></a><code class="literal">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></span></td>
<td>the parent's open file descriptors will be 
 inherited by the child; otherwise all descriptors except stdin/stdout/stderr 
 will be closed before calling <code class="function"><code class="function">exec()</code></code> in the child.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-DO-NOT-REAP-CHILD:CAPS"></a><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></span></td>
<td>the child will not be automatically reaped; you 
  must call <code class="function"><code class="function">waitpid()</code></code> or handle <code class="literal">SIGCHLD</code> 
  yourself, or the child will become a zombie.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-SEARCH-PATH:CAPS"></a><code class="literal">G_SPAWN_SEARCH_PATH</code></span></td>
<td>
<code class="literal">argv[0]</code> need not be an absolute path, 
  it will be looked for in the user's <code class="envar">PATH</code>.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"></a><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></span></td>
<td>the child's standad output will be discarded, 
  instead of going to the same location as the parent's standard output.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-STDERR-TO-DEV-NULL:CAPS"></a><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></span></td>
<td>the child's standard error will be discarded.
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-CHILD-INHERITS-STDIN:CAPS"></a><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></span></td>
<td>the child will inherit the parent's standard 
  input (by default, the child's standard input is attached to 
  <code class="filename">/dev/null</code>).
</td>
</tr>
<tr>
<td>
<span class="term"><a name="G-SPAWN-FILE-AND-ARGV-ZERO:CAPS"></a><code class="literal">G_SPAWN_FILE_AND_ARGV_ZERO</code></span></td>
<td>the first element of <code class="literal">argv</code> is 
  the file to execute, while the remaining elements are the actual argument 
  vector to pass to the file. Normally <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> uses 
  <code class="literal">argv[0]</code> as the file to execute, and passes all of 
  <code class="literal">argv</code> to the child.

</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3103539"></a><h3>
<a name="GSpawnChildSetupFunc"></a>GSpawnChildSetupFunc ()</h3>
<a class="indexterm" name="id3103552"></a><pre class="programlisting">void        (*GSpawnChildSetupFunc)         (<a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Specifies the type of the setup function passed to <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a>,
<a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> and <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a>. On POSIX platforms it
is called in the child after GLib has performed all the setup it plans
to perform but before calling <code class="function"><code class="function">exec()</code></code>. On POSIX
actions taken in this function will thus only affect the child, not
the parent.
</p>
<p>
On Windows the function is called in the parent. Its usefulness on
Windows is thus questionable. In many cases executing the child setup
function in the parent can have ill effects, and you should be very
careful when porting software to Windows that uses child setup
functions.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></td>
<td>user data to pass to the function.


</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3103657"></a><h3>
<a name="g-spawn-async-with-pipes"></a>g_spawn_async_with_pipes ()</h3>
<a class="indexterm" name="id3103670"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_spawn_async_with_pipes        (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> *child_pid,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_input,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_output,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *standard_error,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
<p>
Executes a child program asynchronously (your program will not
block waiting for the child to exit). The child program is
specified by the only argument that must be provided, <em class="parameter"><code>argv</code></em>. <em class="parameter"><code>argv</code></em>
should be a <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated array of strings, to be passed as the
argument vector for the child. The first string in <em class="parameter"><code>argv</code></em> is of
course the name of the program to execute. By default, the name of
the program must be a full path; the <code class="envar">PATH</code> shell variable 
will only be searched if you pass the <a href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag.
</p>
<p>
On Windows, note that all the string or string vector arguments to
this function and the other g_spawn*() functions are in UTF-8, the
GLib file name encoding. Unicode characters that are not part of
the system codepage passed in argument vectors will be correctly
available in the spawned program only if it uses wide character API
to retrieve its command line. For C programs built with Microsoft's
tools it is enough to make the program have a <code class="function">wmain()</code> instead of
<code class="function">main()</code>. <code class="function">wmain()</code> has a wide character argument vector as parameter.
</p>
<p>
At least currently, mingw doesn't support <code class="function">wmain()</code>, so if you use
mingw to develop the spawned program, it will have to call the
undocumented function <code class="function">__wgetmainargs()</code> to get the wide character
argument vector and environment. See gspawn-win32-helper.c in the
GLib sources or init.c in the mingw runtime sources for a prototype
for that function. Alternatively, you can retrieve the Win32 system
level wide character command line passed to the spawned program
using the <code class="function">GetCommandLineW()</code> function.
</p>
<p>
On Windows the low-level child process creation API
<code class="function"><code class="function">CreateProcess()</code></code> doesn't use argument vectors,
but a command line. The C runtime library's
<code class="function">spawn*()</code> family of functions (which
<a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> eventually calls) paste the argument
vector elements together into a command line, and the C runtime startup code
does a corresponding reconstruction of an argument vector from the
command line, to be passed to <code class="function">main()</code>. Complications arise when you have
argument vector elements that contain spaces of double quotes. The
<code class="function">spawn*()</code> functions don't do any quoting or
escaping, but on the other hand the startup code does do unquoting
and unescaping in order to enable receiving arguments with embedded
spaces or double quotes. To work around this asymmetry,
<a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> will do quoting and escaping on argument
vector elements that need it before calling the C runtime
<code class="function">spawn()</code> function.
</p>
<p>
<em class="parameter"><code>envp</code></em> is a <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated array of strings, where each string
has the form <code class="literal">KEY=VALUE</code>. This will become
the child's environment. If <em class="parameter"><code>envp</code></em> is <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the child inherits its
parent's environment.
</p>
<p>
<em class="parameter"><code>flags</code></em> should be the bitwise OR of any flags you want to affect the
function's behaviour. The <a href="glib-Spawning-Processes.html#G-SPAWN-DO-NOT-REAP-CHILD:CAPS"><code class="literal">G_SPAWN_DO_NOT_REAP_CHILD</code></a> means that 
the child will not automatically be reaped; you must use a
<span class="type">GChildWatch</span> source to be notified about the death of the child 
process. Eventually you must call <a href="glib-Spawning-Processes.html#g-spawn-close-pid"><code class="function">g_spawn_close_pid()</code></a> on the
<em class="parameter"><code>child_pid</code></em>, in order to free resources which may be associated
with the child process. (On Unix, using a <span class="type">GChildWatch</span> source is
equivalent to calling <code class="function">waitpid()</code> or handling the <code class="literal">SIGCHLD</code> signal 
manually. On Windows, calling <a href="glib-Spawning-Processes.html#g-spawn-close-pid"><code class="function">g_spawn_close_pid()</code></a> is equivalent
to calling <code class="function">CloseHandle()</code> on the process handle returned in 
<em class="parameter"><code>child_pid</code></em>).
</p>
<p>
<a 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
descriptors will be inherited by the child; otherwise all
descriptors except stdin/stdout/stderr will be closed before
calling <code class="function">exec()</code> in the child. <a href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> 
means that <code class="literal">argv[0]</code> need not be an absolute path, it
will be looked for in the user's <code class="envar">PATH</code>. 
<a 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 
be discarded, instead of going to the same location as the parent's 
standard output. If you use this flag, <em class="parameter"><code>standard_output</code></em> must be <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
<a 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
will be discarded, instead of going to the same location as the parent's
standard error. If you use this flag, <em class="parameter"><code>standard_error</code></em> must be <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
<a 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
standard input (by default, the child's standard input is attached to
/dev/null). If you use this flag, <em class="parameter"><code>standard_input</code></em> must be <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
<a 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
the file to execute, while the remaining elements are the
actual argument vector to pass to the file. Normally
<a href="glib-Spawning-Processes.html#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
passes all of <em class="parameter"><code>argv</code></em> to the child.
</p>
<p>
<em class="parameter"><code>child_setup</code></em> and <em class="parameter"><code>user_data</code></em> are a function and user data. On POSIX
platforms, the function is called in the child after GLib has
performed all the setup it plans to perform (including creating
pipes, closing file descriptors, etc.) but before calling
<code class="function">exec()</code>. That is, <em class="parameter"><code>child_setup</code></em> is called just
before calling <code class="function">exec()</code> in the child. Obviously
actions taken in this function will only affect the child, not the
parent. On Windows, there is no separate <code class="function">fork()</code> and <code class="function">exec()</code>
functionality. Child processes are created and run with
a single API call, <code class="function">CreateProcess()</code>. <em class="parameter"><code>child_setup</code></em> is
called in the parent process just before creating the child
process. You should carefully consider what you do in <em class="parameter"><code>child_setup</code></em>
if you intend your software to be portable to Windows.
</p>
<p>
If non-<a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, <em class="parameter"><code>child_pid</code></em> will on Unix be filled with the child's
process ID. You can use the process ID to send signals to the
child, or to <code class="function">waitpid()</code> if you specified the
<a 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
filled with a handle to the child process only if you specified the
<a 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
process using the Win32 API, for example wait for its termination
with the <code class="function">WaitFor*()</code> functions, or examine its
exit code with <code class="function">GetExitCodeProcess()</code>. You should close the handle 
with <code class="function">CloseHandle()</code> or <a href="glib-Spawning-Processes.html#g-spawn-close-pid"><code class="function">g_spawn_close_pid()</code></a> when you no longer need it.
</p>
<p>
If non-<a href="glib-Standard-Macros.html#NULL:CAPS"><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>
locations will be filled with file descriptors for writing to the child's
standard input or reading from its standard output or standard error.
The caller of <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> must close these file descriptors
when they are no longer in use. If these parameters are <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the corresponding
pipe won't be created.
</p>
<p>
If <em class="parameter"><code>standard_input</code></em> is NULL, the child's standard input is attached to /dev/null
unless <a href="glib-Spawning-Processes.html#G-SPAWN-CHILD-INHERITS-STDIN:CAPS"><code class="literal">G_SPAWN_CHILD_INHERITS_STDIN</code></a> is set.
</p>
<p>
If <em class="parameter"><code>standard_error</code></em> is NULL, the child's standard error goes to the same location
as the parent's standard error unless <a href="glib-Spawning-Processes.html#G-SPAWN-STDERR-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDERR_TO_DEV_NULL</code></a> is set.
</p>
<p>
If <em class="parameter"><code>standard_output</code></em> is NULL, the child's standard output goes to the same location
as the parent's standard output unless <a href="glib-Spawning-Processes.html#G-SPAWN-STDOUT-TO-DEV-NULL:CAPS"><code class="literal">G_SPAWN_STDOUT_TO_DEV_NULL</code></a> is set.
</p>
<p>
<em class="parameter"><code>error</code></em> can be <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors, or non-<a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to report errors.
If an error is set, the function returns <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>. Errors
are reported even if they occur in the child (for example if the
executable in <code class="literal">argv[0]</code> is not found). Typically
the <code class="literal">message</code> field of returned errors should be displayed
to users. Possible errors are those from the <a href="glib-Spawning-Processes.html#G-SPAWN-ERROR:CAPS"><span class="type">G_SPAWN_ERROR</span></a> domain.
</p>
<p>
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>,
and <em class="parameter"><code>standard_error</code></em> will not be filled with valid values.
</p>
<p>
If <em class="parameter"><code>child_pid</code></em> is not <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and an error does not occur then the returned
pid must be closed using <a href="glib-Spawning-Processes.html#g-spawn-close-pid"><code class="function">g_spawn_close_pid()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>working_directory</code></em>&#160;:</span></td>
<td> child's current working directory, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's, in the GLib file name encoding
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>argv</code></em>&#160;:</span></td>
<td> child's argument vector, in the GLib file name encoding
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>envp</code></em>&#160;:</span></td>
<td> child's environment, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's, in the GLib file name encoding
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td>
<td> flags from <a href="glib-Spawning-Processes.html#GSpawnFlags"><span class="type">GSpawnFlags</span></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>child_setup</code></em>&#160;:</span></td>
<td> function to run in the child just before <code class="function">exec()</code>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></td>
<td> user data for <em class="parameter"><code>child_setup</code></em>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>child_pid</code></em>&#160;:</span></td>
<td> return location for child process ID, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_input</code></em>&#160;:</span></td>
<td> return location for file descriptor to write to child's stdin, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_output</code></em>&#160;:</span></td>
<td> return location for file descriptor to read child's stdout, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_error</code></em>&#160;:</span></td>
<td> return location for file descriptor to read child's stderr, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td>
<td> return location for error
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an error was set
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3105076"></a><h3>
<a name="g-spawn-async"></a>g_spawn_async ()</h3>
<a class="indexterm" name="id3105089"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_spawn_async                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> *child_pid,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
<p>
See <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> for a full description; this function
simply calls the <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> without any pipes.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>working_directory</code></em>&#160;:</span></td>
<td> child's current working directory, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>argv</code></em>&#160;:</span></td>
<td> child's argument vector
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>envp</code></em>&#160;:</span></td>
<td> child's environment, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td>
<td> flags from <a href="glib-Spawning-Processes.html#GSpawnFlags"><span class="type">GSpawnFlags</span></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>child_setup</code></em>&#160;:</span></td>
<td> function to run in the child just before <code class="function">exec()</code>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></td>
<td> user data for <em class="parameter"><code>child_setup</code></em>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>child_pid</code></em>&#160;:</span></td>
<td> return location for child process ID, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td>
<td> return location for error
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if error is set
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3105401"></a><h3>
<a name="g-spawn-sync"></a>g_spawn_sync ()</h3>
<a class="indexterm" name="id3105414"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_spawn_sync                    (const <a href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **argv,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **envp,
                                             <a href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,
                                             <a href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *exit_status,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
<p>
Executes a child synchronously (waits for the child to exit before returning).
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>,
if those parameters are non-<a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. If <em class="parameter"><code>exit_status</code></em> is non-<a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the exit 
status of the child is stored there as it would be returned by 
<code class="function">waitpid()</code>; standard UNIX macros such as <code class="function">WIFEXITED()</code> and <code class="function">WEXITSTATUS()</code> 
must be used to evaluate the exit status. If an error occurs, no data is 
returned in <em class="parameter"><code>standard_output</code></em>, <em class="parameter"><code>standard_error</code></em>, or <em class="parameter"><code>exit_status</code></em>.
</p>
<p>
This function calls <a href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> internally; see that
function for full details on the other parameters and details on
how these functions work on Windows.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>working_directory</code></em>&#160;:</span></td>
<td> child's current working directory, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>argv</code></em>&#160;:</span></td>
<td> child's argument vector
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>envp</code></em>&#160;:</span></td>
<td> child's environment, or <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></td>
<td> flags from <a href="glib-Spawning-Processes.html#GSpawnFlags"><span class="type">GSpawnFlags</span></a>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>child_setup</code></em>&#160;:</span></td>
<td> function to run in the child just before <code class="function">exec()</code>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></td>
<td> user data for <em class="parameter"><code>child_setup</code></em>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_output</code></em>&#160;:</span></td>
<td> return location for child output 
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_error</code></em>&#160;:</span></td>
<td> return location for child error messages
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>exit_status</code></em>&#160;:</span></td>
<td> return location for child exit status, as returned by <code class="function">waitpid()</code>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td>
<td> return location for error
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an error was set.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3105860"></a><h3>
<a name="g-spawn-command-line-async"></a>g_spawn_command_line_async ()</h3>
<a class="indexterm" name="id3105874"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_spawn_command_line_async      (const <a href="glib-Basic-Types.html#gchar">gchar</a> *command_line,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
<p>
A simple version of <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a> that parses a command line with
<a href="glib-Shell-related-Utilities.html#g-shell-parse-argv"><code class="function">g_shell_parse_argv()</code></a> and passes it to <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a>. Runs a
command line in the background. Unlike <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a>, the
<a 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
that <a href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security implications, so
consider using <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a> directly if appropriate. Possible
errors are those from <a href="glib-Shell-related-Utilities.html#g-shell-parse-argv"><code class="function">g_shell_parse_argv()</code></a> and <a href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a>.
</p>
<p>
The same concerns on Windows apply as for <a href="glib-Spawning-Processes.html#g-spawn-command-line-sync"><code class="function">g_spawn_command_line_sync()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>command_line</code></em>&#160;:</span></td>
<td> a command line
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td>
<td> return location for errors
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if error is set.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3106093"></a><h3>
<a name="g-spawn-command-line-sync"></a>g_spawn_command_line_sync ()</h3>
<a class="indexterm" name="id3106107"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_spawn_command_line_sync       (const <a href="glib-Basic-Types.html#gchar">gchar</a> *command_line,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,
                                             <a href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,
                                             <a href="glib-Basic-Types.html#gint">gint</a> *exit_status,
                                             <a href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
<p>
A simple version of <a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> with little-used parameters
removed, taking a command line instead of an argument vector.  See
<a href="glib-Spawning-Processes.html#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
<a href="glib-Shell-related-Utilities.html#g-shell-parse-argv"><code class="function">g_shell_parse_argv()</code></a>. Unlike <a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a>, the <a href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> flag
is enabled. Note that <a href="glib-Spawning-Processes.html#G-SPAWN-SEARCH-PATH:CAPS"><code class="literal">G_SPAWN_SEARCH_PATH</code></a> can have security
implications, so consider using <a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> directly if
appropriate. Possible errors are those from <a href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> and those
from <a href="glib-Shell-related-Utilities.html#g-shell-parse-argv"><code class="function">g_shell_parse_argv()</code></a>.
</p>
<p>
If <em class="parameter"><code>exit_status</code></em> is non-<a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the exit status of the child is stored there as
it would be returned by <code class="function">waitpid()</code>; standard UNIX macros such as <code class="function">WIFEXITED()</code>
and <code class="function">WEXITSTATUS()</code> must be used to evaluate the exit status.
</p>
<p>
On Windows, please note the implications of <a href="glib-Shell-related-Utilities.html#g-shell-parse-argv"><code class="function">g_shell_parse_argv()</code></a>
parsing <em class="parameter"><code>command_line</code></em>. Parsing is done according to Unix shell rules, not 
Windows command interpreter rules.
Space is a separator, and backslashes are
special. Thus you cannot simply pass a <em class="parameter"><code>command_line</code></em> containing
canonical Windows paths, like "c:\\program files\\app\\app.exe", as
the backslashes will be eaten, and the space will act as a
separator. You need to enclose such paths with single quotes, like
"'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>command_line</code></em>&#160;:</span></td>
<td> a command line 
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_output</code></em>&#160;:</span></td>
<td> return location for child output
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>standard_error</code></em>&#160;:</span></td>
<td> return location for child errors
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>exit_status</code></em>&#160;:</span></td>
<td> return location for child exit status, as returned by <code class="function">waitpid()</code>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></td>
<td> return location for errors
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> <a href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an error was set
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3106480"></a><h3>
<a name="g-spawn-close-pid"></a>g_spawn_close_pid ()</h3>
<a class="indexterm" name="id3106494"></a><pre class="programlisting">void        g_spawn_close_pid               (<a href="glib-The-Main-Event-Loop.html#GPid">GPid</a> pid);</pre>
<p>
On some platforms, notably WIN32, the <a href="glib-The-Main-Event-Loop.html#GPid"><span class="type">GPid</span></a> type represents a resource
which must be closed to prevent resource leaking. <a href="glib-Spawning-Processes.html#g-spawn-close-pid"><code class="function">g_spawn_close_pid()</code></a>
is provided for this purpose. It should be used on all platforms, even
though it doesn't do anything under UNIX.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><em class="parameter"><code>pid</code></em>&#160;:</span></td>
<td> The process identifier to close
</td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>

Anon7 - 2021