mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Add g_spawn_check_exit_status()
Many (if not "almost all") programs that spawn other programs via g_spawn_sync() or the like simply want to check whether or not the child exited successfully, but doing so requires use of platform-specific functionality and there's actually a fair amount of boilerplate involved. This new API will help drain a *lot* of mostly duplicated code in GNOME, from gnome-session to gdm. And we can see that some bits even inside GLib were doing it wrong; for example checking the exit status on Unix, but ignoring it on Windows. https://bugzilla.gnome.org/show_bug.cgi?id=679691
This commit is contained in:
@@ -25,9 +25,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#include "gdbus-tests.h"
|
||||
|
||||
@@ -97,10 +94,8 @@ test_connection_flush (void)
|
||||
&exit_status,
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
g_assert (WIFEXITED (exit_status));
|
||||
g_assert_cmpint (WEXITSTATUS (exit_status), ==, 0);
|
||||
#endif
|
||||
g_spawn_check_exit_status (exit_status, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
|
||||
timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n));
|
||||
|
Reference in New Issue
Block a user