diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2024-05-10 01:17:15 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2024-05-10 04:16:17 +0200 |
commit | 1d2d865f47e10b6574ce295ebc37739619d761d7 (patch) | |
tree | b47e7c8897413b50ee2dea7920529a099db1086c | |
parent | f7b1ed1bf35bc9a0dd692f5ab6fc0e4ecdca67d1 (diff) | |
download | glib-1d2d865f47e10b6574ce295ebc37739619d761d7.tar.gz |
glib/tests/mapping: Check the exit status of the child process
In this way if it fails for some memory error we can track it
-rw-r--r-- | glib/tests/mapping.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/glib/tests/mapping.c b/glib/tests/mapping.c index 99cb8eee0..5fcde83ae 100644 --- a/glib/tests/mapping.c +++ b/glib/tests/mapping.c @@ -22,6 +22,7 @@ #ifdef G_OS_UNIX #include <unistd.h> +#include <sys/wait.h> #endif #ifdef G_OS_WIN32 #include <process.h> @@ -201,8 +202,10 @@ test_child_private (void) gsize len; gchar *child_argv[4]; GPid child_pid; + GSpawnFlags spawn_flags = G_SPAWN_DEFAULT; #ifndef G_OS_WIN32 GMainLoop *loop; + int wait_status; #endif gchar pid[100]; gchar *dir, *global_filename, *childname; @@ -221,6 +224,7 @@ test_child_private (void) #ifndef G_OS_WIN32 signal (SIGUSR1, handle_usr1); + spawn_flags |= G_SPAWN_DO_NOT_REAP_CHILD; #endif g_snprintf (pid, sizeof(pid), "%d", getpid ()); @@ -230,7 +234,7 @@ test_child_private (void) child_argv[3] = NULL; result = g_spawn_async (dir, child_argv, NULL, - 0, NULL, NULL, &child_pid, &error); + spawn_flags, NULL, NULL, &child_pid, &error); g_assert_no_error (error); g_assert_true (result); g_test_message ("test_child_private: child spawned"); @@ -261,6 +265,10 @@ test_child_private (void) #ifndef G_OS_WIN32 g_idle_add (check_stop, loop); g_main_loop_run (loop); + waitpid (child_pid, &wait_status, 0); + g_test_message ("Child exited with status %d", wait_status); + g_spawn_check_wait_status (wait_status, &error); + g_assert_no_error (error); #else g_usleep (2000000); #endif |