mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-16 18:51:58 +02:00
glib/gtester.c:Quit the application when the output is parsed completely, not just the process finished
svn path=/trunk/; revision=5891
This commit is contained in:
parent
dce1a63bf4
commit
a09ee4dc20
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
static GIOChannel* out = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
child_watch_cb (GPid pid,
|
child_watch_cb (GPid pid,
|
||||||
gint status,
|
gint status,
|
||||||
@ -30,7 +32,9 @@ child_watch_cb (GPid pid,
|
|||||||
{
|
{
|
||||||
GMainLoop* loop = data;
|
GMainLoop* loop = data;
|
||||||
|
|
||||||
g_main_loop_quit (loop);
|
g_spawn_close_pid (pid);
|
||||||
|
|
||||||
|
//g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -40,20 +44,22 @@ child_out_cb (GIOChannel * source,
|
|||||||
{
|
{
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
gsize length = 0;
|
gsize length = 0;
|
||||||
gchar buffer[4096];
|
gchar buffer[10];
|
||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
|
|
||||||
status = g_io_channel_read_chars (source, buffer, sizeof (buffer), &length, &error);
|
status = g_io_channel_read_chars (source, buffer, sizeof (buffer), &length, &error);
|
||||||
if (status == G_IO_STATUS_NORMAL)
|
if (status == G_IO_STATUS_NORMAL)
|
||||||
{
|
{
|
||||||
g_print ("%d\n", length);
|
g_print ("%d\n", length);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (status != G_IO_STATUS_NORMAL || length != sizeof (buffer))
|
||||||
{
|
{
|
||||||
g_print ("Output done: %d\n", status);
|
g_main_loop_quit (data);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -70,7 +76,6 @@ main (int argc,
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
gint child_out;
|
gint child_out;
|
||||||
GIOChannel* out;
|
|
||||||
|
|
||||||
working_folder = g_get_current_dir ();
|
working_folder = g_get_current_dir ();
|
||||||
g_spawn_async_with_pipes (working_folder,
|
g_spawn_async_with_pipes (working_folder,
|
||||||
@ -98,7 +103,7 @@ main (int argc,
|
|||||||
|
|
||||||
out = g_io_channel_unix_new (child_out);
|
out = g_io_channel_unix_new (child_out);
|
||||||
g_io_add_watch (out, G_IO_IN,
|
g_io_add_watch (out, G_IO_IN,
|
||||||
child_out_cb, NULL);
|
child_out_cb, loop);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user