⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-spawning-processes.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<hr><div class="refsect2" lang="en"><a name="id3100997"></a><h3><a name="g-spawn-sync"></a>g_spawn_sync ()</h3><a class="indexterm" name="id3101010"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            g_spawn_sync                        (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *working_directory,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **argv,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **envp,                                                         <a class="link" href="glib-Spawning-Processes.html#GSpawnFlags">GSpawnFlags</a> flags,                                                         <a class="link" href="glib-Spawning-Processes.html#GSpawnChildSetupFunc">GSpawnChildSetupFunc</a> child_setup,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,                                                         <a class="link" href="glib-Basic-Types.html#gint">gint</a> *exit_status,                                                         <a class="link" 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 class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. Note that you must set the  <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 whenpassing <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> for <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>.If <em class="parameter"><code>exit_status</code></em> is non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the exit status of the child is storedthere 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.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"><code class="literal">NULL</code></a>, anddoes 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.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 class="link" href="glib-Spawning-Processes.html#g-spawn-async-with-pipes"><code class="function">g_spawn_async_with_pipes()</code></a> internally; see thatfunction for full details on the other parameters and details onhow these functions work on Windows.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>working_directory</code></em>&#160;:</span></p></td><td> child's current working directory, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's</td></tr><tr><td><p><span class="term"><em class="parameter"><code>argv</code></em>&#160;:</span></p></td><td> child's argument vector</td></tr><tr><td><p><span class="term"><em class="parameter"><code>envp</code></em>&#160;:</span></p></td><td> child's environment, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to inherit parent's</td></tr><tr><td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td><td> flags from <a class="link" href="glib-Spawning-Processes.html#GSpawnFlags"><span class="type">GSpawnFlags</span></a> </td></tr><tr><td><p><span class="term"><em class="parameter"><code>child_setup</code></em>&#160;:</span></p></td><td> function to run in the child just before <code class="function">exec()</code></td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td><td> user data for <em class="parameter"><code>child_setup</code></em></td></tr><tr><td><p><span class="term"><em class="parameter"><code>standard_output</code></em>&#160;:</span></p></td><td> return location for child output, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>standard_error</code></em>&#160;:</span></p></td><td> return location for child error messages, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>exit_status</code></em>&#160;:</span></p></td><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"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for error, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" 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="id3101583"></a><h3><a name="g-spawn-command-line-async"></a>g_spawn_command_line_async ()</h3><a class="indexterm" name="id3101596"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            g_spawn_command_line_async          (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *command_line,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>A simple version of <a class="link" href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a> that parses a command line with<a class="link" href="glib-Shell-related-Utilities.html#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"><code class="function">g_spawn_async()</code></a>. Runs acommand line in the background. Unlike <a class="link" href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</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 is enabled, other flags are not. Notethat <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, soconsider using <a class="link" href="glib-Spawning-Processes.html#g-spawn-async"><code class="function">g_spawn_async()</code></a> directly if appropriate. Possibleerrors are those from <a class="link" href="glib-Shell-related-Utilities.html#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"><code class="function">g_spawn_async()</code></a>.</p><p>The same concerns on Windows apply as for <a class="link" 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><p><span class="term"><em class="parameter"><code>command_line</code></em>&#160;:</span></p></td><td> a command line</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for errors</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" 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="id3101816"></a><h3><a name="g-spawn-command-line-sync"></a>g_spawn_command_line_sync ()</h3><a class="indexterm" name="id3101829"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            g_spawn_command_line_sync           (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *command_line,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **standard_output,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **standard_error,                                                         <a class="link" href="glib-Basic-Types.html#gint">gint</a> *exit_status,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>A simple version of <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> with little-used parametersremoved, taking a command line instead of an argument vector.  See<a class="link" 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 class="link" href="glib-Shell-related-Utilities.html#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"><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> flagis 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 securityimplications, so consider using <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> directly ifappropriate. Possible errors are those from <a class="link" href="glib-Spawning-Processes.html#g-spawn-sync"><code class="function">g_spawn_sync()</code></a> and thosefrom <a class="link" 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 class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the exit status of the child is stored there asit 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 class="link" 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 arespecial. Thus you cannot simply pass a <em class="parameter"><code>command_line</code></em> containingcanonical Windows paths, like "c:\\program files\\app\\app.exe", asthe backslashes will be eaten, and the space will act as aseparator. 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><p><span class="term"><em class="parameter"><code>command_line</code></em>&#160;:</span></p></td><td> a command line </td></tr><tr><td><p><span class="term"><em class="parameter"><code>standard_output</code></em>&#160;:</span></p></td><td> return location for child output</td></tr><tr><td><p><span class="term"><em class="parameter"><code>standard_error</code></em>&#160;:</span></p></td><td> return location for child errors</td></tr><tr><td><p><span class="term"><em class="parameter"><code>exit_status</code></em>&#160;:</span></p></td><td> return location for child exit status, as returned by <code class="function">waitpid()</code></td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for errors</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" 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="id3102204"></a><h3><a name="g-spawn-close-pid"></a>g_spawn_close_pid ()</h3><a class="indexterm" name="id3102217"></a><pre class="programlisting">void                g_spawn_close_pid                   (<a class="link" href="glib-The-Main-Event-Loop.html#GPid">GPid</a> pid);</pre><p>On some platforms, notably WIN32, the <a class="link" href="glib-The-Main-Event-Loop.html#GPid"><span class="type">GPid</span></a> type represents a resourcewhich must be closed to prevent resource leaking. <a class="link" 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, eventhough it doesn't do anything under UNIX.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>pid</code></em>&#160;:</span></p></td><td> The process identifier to close</td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id3102290"></a><div class="refsect2" lang="en"><a name="id3102291"></a></div><hr><div class="refsect2" lang="en"><a name="id3102292"></a></div></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -