📄 spawn.sgml
字号:
<refentry id="glib-Spawning-Processes"><refmeta><refentrytitle>Spawning Processes</refentrytitle><manvolnum>3</manvolnum><refmiscinfo>GLIB Library</refmiscinfo></refmeta><refnamediv><refname>Spawning Processes</refname><refpurpose>process launching with <function><link linkend="fork">fork</link>()</function>/<function><link linkend="exec">exec</link>()</function>.</refpurpose></refnamediv><refsynopsisdiv><title>Synopsis</title><synopsis>#include <glib.h>enum <link linkend="GSpawnError">GSpawnError</link>;#define <link linkend="G-SPAWN-ERROR-CAPS">G_SPAWN_ERROR</link>enum <link linkend="GSpawnFlags">GSpawnFlags</link>;void (<link linkend="GSpawnChildSetupFunc">*GSpawnChildSetupFunc</link>) (<link linkend="gpointer">gpointer</link> user_data);<link linkend="gboolean">gboolean</link> <link linkend="g-spawn-async-with-pipes">g_spawn_async_with_pipes</link> (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="gint">gint</link> *standard_input, <link linkend="gint">gint</link> *standard_output, <link linkend="gint">gint</link> *standard_error, <link linkend="GError">GError</link> **error);<link linkend="gboolean">gboolean</link> <link linkend="g-spawn-async">g_spawn_async</link> (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);<link linkend="gboolean">gboolean</link> <link linkend="g-spawn-sync">g_spawn_sync</link> (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);<link linkend="gboolean">gboolean</link> <link linkend="g-spawn-command-line-async">g_spawn_command_line_async</link> (const <link linkend="gchar">gchar</link> *command_line, <link linkend="GError">GError</link> **error);<link linkend="gboolean">gboolean</link> <link linkend="g-spawn-command-line-sync">g_spawn_command_line_sync</link> (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);</synopsis></refsynopsisdiv><refsect1><title>Description</title><para></para></refsect1><refsect1><title>Details</title><refsect2><title><anchor id="GSpawnError">enum GSpawnError</title><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->message * should explain */} GSpawnError;</programlisting><para>Error codes returned by spawning processes.</para><informaltable pgwide="1" frame="none" role="enum"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry><literal>G_SPAWN_ERROR_FORK</literal></entry><entry>Fork failed due to lack of memory.</entry></row><row><entry><literal>G_SPAWN_ERROR_READ</literal></entry><entry>Read or select on pipes failed.</entry></row><row><entry><literal>G_SPAWN_ERROR_CHDIR</literal></entry><entry>Changing to working directory failed.</entry></row><row><entry><literal>G_SPAWN_ERROR_ACCES</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EACCES</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_PERM</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EPERM</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_2BIG</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>E2BIG</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NOEXEC</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENOEXEC</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NAMETOOLONG</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENAMETOOLONG</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NOENT</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENOENT</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NOMEM</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENOMEM</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NOTDIR</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENOTDIR</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_LOOP</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ELOOP</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_TXTBUSY</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ETXTBUSY</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_IO</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EIO</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_NFILE</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ENFILE</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_MFILE</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EMFILE</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_INVAL</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EINVAL</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_ISDIR</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>EISDIR</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_LIBBAD</literal></entry><entry><function><link linkend="execv">execv</link>()</function> returned <literal>ELIBBAD</literal>.</entry></row><row><entry><literal>G_SPAWN_ERROR_FAILED</literal></entry><entry>Some other fatal failure, <literal>error->message</literal> should explain.</entry></row></tbody></tgroup></informaltable></refsect2>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -