mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-03 17:48:56 +01:00 
			
		
		
		
	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
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user