📄 glib-spawning-processes.html
字号:
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><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.0"><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.4 (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"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" 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></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><span class="refentrytitle">Spawning Processes</span></h2><p>Spawning Processes — 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 <glib.h>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="id3043820"></a><h2>Description</h2><p></p></div><div class="refsect1" lang="en"><a name="id3043830"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3043835"></a><h3><a name="GSpawnError"></a>enum GSpawnError</h3><a class="indexterm" name="id3043846"></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->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"><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"><code class="literal">G_SPAWN_ERROR_READ</code></span></td><td>Read or select on pipes failed.</td></tr><tr><td><span class="term"><code class="literal">G_SPAWN_ERROR_CHDIR</code></span></td><td>Changing to working directory failed.</td></tr><tr><td><span class="term"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><code class="literal">G_SPAWN_ERROR_MFILE</code></span></td><td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -