[gitg] Fixed reaping childs and registering exit code
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Fixed reaping childs and registering exit code
- Date: Sun, 5 Jul 2009 01:14:25 +0000 (UTC)
commit 1693ec3d4353c731c21678b52d69e955951fb14a
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sat Jul 4 20:07:57 2009 +0200
Fixed reaping childs and registering exit code
gitg/gitg-runner.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gitg/gitg-runner.c b/gitg/gitg-runner.c
index f5fcea6..1fdd3d1 100644
--- a/gitg/gitg-runner.c
+++ b/gitg/gitg-runner.c
@@ -26,6 +26,8 @@
#include <sys/types.h>
#include <sys/wait.h>
#include "gitg-debug.h"
+#include <errno.h>
+#include <stdlib.h>
#include <gio/gio.h>
#include <gio/gunixoutputstream.h>
@@ -117,6 +119,11 @@ runner_io_exit(GPid pid, gint status, GitgRunner *runner)
}
static void
+dummy_exit(GPid pid, gint status, gpointer data)
+{
+}
+
+static void
free_lines(GitgRunner *runner)
{
gint i = 0;
@@ -406,7 +413,7 @@ run_sync(GitgRunner *runner, gchar const *input, GError **error)
parse_lines(runner, runner->priv->read_buffer, read);
}
- gint status;
+ gint status = 0;
waitpid(runner->priv->pid, &status, 0);
runner_io_exit(runner->priv->pid, status, runner);
@@ -466,8 +473,9 @@ read_output_ready(GInputStream *stream, GAsyncResult *result, AsyncData *data)
gchar *b[] = {data->runner->priv->buffer, NULL};
g_signal_emit(data->runner, runner_signals[UPDATE], 0, b);
- gint status;
+ gint status = 0;
waitpid(data->runner->priv->pid, &status, 0);
+
runner_io_exit(data->runner->priv->pid, status, data->runner);
close_streams(data->runner);
@@ -574,8 +582,6 @@ gitg_runner_run_with_arguments(GitgRunner *runner, gchar const **argv, gchar con
return FALSE;
}
- g_child_watch_add (runner->priv->pid, (GChildWatchFunc)runner_io_exit, runner);
-
GInputStream *input_stream = NULL;
GOutputStream *output_stream = NULL;
@@ -619,6 +625,11 @@ gitg_runner_get_buffer_size(GitgRunner *runner)
return runner->priv->buffer_size;
}
+static void
+dummy_cb(GPid pid, gint status, gpointer data)
+{
+}
+
void
gitg_runner_cancel(GitgRunner *runner)
{
@@ -631,9 +642,10 @@ gitg_runner_cancel(GitgRunner *runner)
runner->priv->cancellable = g_cancellable_new();
+ g_child_watch_add(runner->priv->pid, dummy_cb, NULL);
kill(runner->priv->pid, SIGTERM);
- runner_io_exit(runner->priv->pid, 1, runner);
+ runner_io_exit(runner->priv->pid, EXIT_FAILURE, runner);
close_streams(runner);
g_signal_emit(runner, runner_signals[END_LOADING], 0, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]