📄 spawn.sgml
字号:
<entry> user data for <parameter>child_setup</parameter></entry></row><row><entry align="right"><parameter>child_pid</parameter> :</entry><entry> return location for child process ID, or <literal>NULL</literal></entry></row><row><entry align="right"><parameter>standard_input</parameter> :</entry><entry> return location for file descriptor to write to child's stdin, or <literal>NULL</literal></entry></row><row><entry align="right"><parameter>standard_output</parameter> :</entry><entry> return location for file descriptor to read child's stdout, or <literal>NULL</literal></entry></row><row><entry align="right"><parameter>standard_error</parameter> :</entry><entry> return location for file descriptor to read child's stderr, or <literal>NULL</literal></entry></row><row><entry align="right"><parameter>error</parameter> :</entry><entry> return location for error</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> on success, <literal>FALSE</literal> if an error was set</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-spawn-async">g_spawn_async ()</title><programlisting><link linkend="gboolean">gboolean</link> g_spawn_async (const <link linkend="gchar">gchar</link> *working_directory, <link linkend="gchar">gchar</link> **argv, <link linkend="gchar">gchar</link> **envp, <link linkend="GSpawnFlags">GSpawnFlags</link> flags, <link linkend="GSpawnChildSetupFunc">GSpawnChildSetupFunc</link> child_setup, <link linkend="gpointer">gpointer</link> user_data, <link linkend="gint">gint</link> *child_pid, <link linkend="GError">GError</link> **error);</programlisting><para>See <link linkend="g-spawn-async-with-pipes">g_spawn_async_with_pipes</link>() for a full description; this functionsimply calls the <link linkend="g-spawn-async-with-pipes">g_spawn_async_with_pipes</link>() without any pipes.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>working_directory</parameter> :</entry><entry> child's current working directory, or <literal>NULL</literal> to inherit parent's</entry></row><row><entry align="right"><parameter>argv</parameter> :</entry><entry> child's argument vector</entry></row><row><entry align="right"><parameter>envp</parameter> :</entry><entry> child's environment, or <literal>NULL</literal> to inherit parent's</entry></row><row><entry align="right"><parameter>flags</parameter> :</entry><entry> flags from <link linkend="GSpawnFlags">GSpawnFlags</link></entry></row><row><entry align="right"><parameter>child_setup</parameter> :</entry><entry> function to run in the child just before <function><link linkend="exec">exec</link>()</function></entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry> user data for <parameter>child_setup</parameter></entry></row><row><entry align="right"><parameter>child_pid</parameter> :</entry><entry> return location for child process ID, or <literal>NULL</literal></entry></row><row><entry align="right"><parameter>error</parameter> :</entry><entry> return location for error</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> on success, <literal>FALSE</literal> if error is set</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-spawn-sync">g_spawn_sync ()</title><programlisting><link linkend="gboolean">gboolean</link> g_spawn_sync (const <link linkend="gchar">gchar</link> *working_directory, <link linkend="gchar">gchar</link> **argv, <link linkend="gchar">gchar</link> **envp, <link linkend="GSpawnFlags">GSpawnFlags</link> flags, <link linkend="GSpawnChildSetupFunc">GSpawnChildSetupFunc</link> child_setup, <link linkend="gpointer">gpointer</link> user_data, <link linkend="gchar">gchar</link> **standard_output, <link linkend="gchar">gchar</link> **standard_error, <link linkend="gint">gint</link> *exit_status, <link linkend="GError">GError</link> **error);</programlisting><para>Executes a child synchronously (waits for the child to exit before returning).All output from the child is stored in <parameter>standard_output</parameter> and <parameter>standard_error</parameter>,if those parameters are non-<literal>NULL</literal>. If <parameter>exit_status</parameter> is non-<literal>NULL</literal>, the exit status of the child is stored there as it would be returned by <function><link linkend="waitpid">waitpid</link>()</function>; standard UNIX macros such as <function><link linkend="WIFEXITED-CAPS">WIFEXITED</link>()</function> and <function><link linkend="WEXITSTATUS-CAPS">WEXITSTATUS</link>()</function> must be used to evaluate the exit status. If an error occurs, no data is returned in <parameter>standard_output</parameter>, <parameter>standard_error</parameter>, or <parameter>exit_status</parameter>.</para><para>This function calls <link linkend="g-spawn-async-with-pipes">g_spawn_async_with_pipes</link>() internally; see that functionfor full details on the other parameters.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>working_directory</parameter> :</entry><entry> child's current working directory, or <literal>NULL</literal> to inherit parent's</entry></row><row><entry align="right"><parameter>argv</parameter> :</entry><entry> child's argument vector</entry></row><row><entry align="right"><parameter>envp</parameter> :</entry><entry> child's environment, or <literal>NULL</literal> to inherit parent's</entry></row><row><entry align="right"><parameter>flags</parameter> :</entry><entry> flags from <link linkend="GSpawnFlags">GSpawnFlags</link></entry></row><row><entry align="right"><parameter>child_setup</parameter> :</entry><entry> function to run in the child just before <function><link linkend="exec">exec</link>()</function></entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry> user data for <parameter>child_setup</parameter></entry></row><row><entry align="right"><parameter>standard_output</parameter> :</entry><entry> return location for child output </entry></row><row><entry align="right"><parameter>standard_error</parameter> :</entry><entry> return location for child error messages</entry></row><row><entry align="right"><parameter>exit_status</parameter> :</entry><entry> child exit status, as returned by <function><link linkend="waitpid">waitpid</link>()</function></entry></row><row><entry align="right"><parameter>error</parameter> :</entry><entry> return location for error</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> on success, <literal>FALSE</literal> if an error was set.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-spawn-command-line-async">g_spawn_command_line_async ()</title><programlisting><link linkend="gboolean">gboolean</link> g_spawn_command_line_async (const <link linkend="gchar">gchar</link> *command_line, <link linkend="GError">GError</link> **error);</programlisting><para>A simple version of <link linkend="g-spawn-async">g_spawn_async</link>() that parses a command line with<link linkend="g-shell-parse-argv">g_shell_parse_argv</link>() and passes it to <link linkend="g-spawn-async">g_spawn_async</link>(). Runs acommand line in the background. Unlike <link linkend="g-spawn-async">g_spawn_async</link>(), the<literal>G_SPAWN_SEARCH_PATH</literal> flag is enabled, other flags are not. Notethat <literal>G_SPAWN_SEARCH_PATH</literal> can have security implications, soconsider using <link linkend="g-spawn-async">g_spawn_async</link>() directly if appropriate. Possibleerrors are those from <link linkend="g-shell-parse-argv">g_shell_parse_argv</link>() and <link linkend="g-spawn-async">g_spawn_async</link>().</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>command_line</parameter> :</entry><entry> a command line</entry></row><row><entry align="right"><parameter>error</parameter> :</entry><entry> return location for errors</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> on success, <literal>FALSE</literal> if error is set.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-spawn-command-line-sync">g_spawn_command_line_sync ()</title><programlisting><link linkend="gboolean">gboolean</link> g_spawn_command_line_sync (const <link linkend="gchar">gchar</link> *command_line, <link linkend="gchar">gchar</link> **standard_output, <link linkend="gchar">gchar</link> **standard_error, <link linkend="gint">gint</link> *exit_status, <link linkend="GError">GError</link> **error);</programlisting><para>A simple version of <link linkend="g-spawn-sync">g_spawn_sync</link>() with little-used parametersremoved, taking a command line instead of an argument vector. See<link linkend="g-spawn-sync">g_spawn_sync</link>() for full details. <parameter>command_line</parameter> will be parsed by<link linkend="g-shell-parse-argv">g_shell_parse_argv</link>(). Unlike <link linkend="g-spawn-sync">g_spawn_sync</link>(), the <literal>G_SPAWN_SEARCH_PATH</literal> flagis enabled. Note that <literal>G_SPAWN_SEARCH_PATH</literal> can have securityimplications, so consider using <link linkend="g-spawn-sync">g_spawn_sync</link>() directly ifappropriate. Possible errors are those from <link linkend="g-spawn-sync">g_spawn_sync</link>() and thosefrom <link linkend="g-shell-parse-argv">g_shell_parse_argv</link>().</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>command_line</parameter> :</entry><entry> a command line </entry></row><row><entry align="right"><parameter>standard_output</parameter> :</entry><entry> return location for child output</entry></row><row><entry align="right"><parameter>standard_error</parameter> :</entry><entry> return location for child errors</entry></row><row><entry align="right"><parameter>exit_status</parameter> :</entry><entry> return location for child exit status</entry></row><row><entry align="right"><parameter>error</parameter> :</entry><entry> return location for errors</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <literal>TRUE</literal> on success, <literal>FALSE</literal> if an error was set</entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -