[geany/geany] 8aebf5: Fix spawn_async_with_pipes() to work without watch for child_pid=NULL
Dimitar Zhekov
git-noreply at xxxxx
Fri Jun 26 15:44:56 UTC 2015
Branch: refs/heads/master
Author: Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer: Dimitar Zhekov <dimitar.zhekov at gmail.com>
Date: Fri, 26 Jun 2015 15:44:56 UTC
Commit: 8aebf54b4716c7ca443851c1c72e6bc926e03371
https://github.com/geany/geany/commit/8aebf54b4716c7ca443851c1c72e6bc926e03371
Log Message:
-----------
Fix spawn_async_with_pipes() to work without watch for child_pid=NULL
On child_pid=NULL, the Windows process handle is now closed ASAP, so
no main glib event loop is required.
Modified Paths:
--------------
src/spawn.c
Modified: src/spawn.c
18 lines changed, 6 insertions(+), 12 deletions(-)
===================================================================
@@ -360,7 +360,11 @@ static gchar *spawn_create_process_with_pipes(char *command_line, const char *wo
{
failed = NULL;
CloseHandle(process.hThread); /* we don't need this */
- *hprocess = process.hProcess;
+
+ if (hprocess)
+ *hprocess = process.hProcess;
+ else
+ CloseHandle(process.hProcess);
}
leave:
@@ -444,12 +448,6 @@ static void spawn_append_argument(GString *command, const char *text)
g_string_append_c(command, '"');
}
}
-
-
-static void spawn_close_pid(GPid pid, G_GNUC_UNUSED gint status, G_GNUC_UNUSED gpointer data)
-{
- g_spawn_close_pid(pid);
-}
#endif /* G_OS_WIN32 */
@@ -491,7 +489,6 @@ gboolean spawn_async_with_pipes(const gchar *working_directory, const gchar *com
#ifdef G_OS_WIN32
GString *command;
GArray *environment;
- GPid pid;
gchar *failure;
if (command_line)
@@ -539,8 +536,7 @@ gboolean spawn_async_with_pipes(const gchar *working_directory, const gchar *com
}
failure = spawn_create_process_with_pipes(command->str, working_directory,
- envp ? environment->data : NULL, child_pid ? child_pid : &pid,
- stdin_fd, stdout_fd, stderr_fd);
+ envp ? environment->data : NULL, child_pid, stdin_fd, stdout_fd, stderr_fd);
g_string_free(command, TRUE);
g_array_free(environment, TRUE);
@@ -551,8 +547,6 @@ gboolean spawn_async_with_pipes(const gchar *working_directory, const gchar *com
g_free(failure);
return FALSE;
}
- else if (!child_pid)
- g_child_watch_add(pid, spawn_close_pid, NULL);
return TRUE;
#else /* G_OS_WIN32 */
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list