Merge branch 'gbsneto/fix-gsubprocess-pid' into 'main'

gio/subprocess: Initialize pid variable to 0

See merge request GNOME/glib!4494
This commit is contained in:
Philip Withnall 2025-02-15 10:12:02 +00:00
commit 4738951270
2 changed files with 18 additions and 1 deletions

View File

@ -305,7 +305,7 @@ initable_init (GInitable *initable,
gint *pipe_ptrs[3] = { NULL, NULL, NULL };
gint pipe_fds[3] = { -1, -1, -1 };
gint close_fds[3] = { -1, -1, -1 };
GPid pid;
GPid pid = 0;
#ifdef G_OS_UNIX
gint stdin_fd = -1, stdout_fd = -1, stderr_fd = -1;
#endif

View File

@ -1352,6 +1352,22 @@ test_terminate (void)
g_object_unref (proc);
}
static void
test_fail_initialization (void)
{
GError *local_error = NULL;
GError **error = &local_error;
GSubprocess *proc;
proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE,
error,
"thisprogramshouldnotexistprettyplease",
NULL);
g_assert_null (proc);
g_assert_error (local_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT);
}
#ifdef G_OS_UNIX
static void
send_signal (gpointer user_data)
@ -2244,6 +2260,7 @@ main (int argc, char **argv)
g_test_add_func ("/gsubprocess/communicate/utf8/invalid", test_communicate_utf8_invalid);
g_test_add_func ("/gsubprocess/communicate/nothing", test_communicate_nothing);
g_test_add_func ("/gsubprocess/terminate", test_terminate);
g_test_add_func ("/gsubprocess/fail-initialization", test_fail_initialization);
g_test_add_func ("/gsubprocess/env", test_env);
g_test_add_func ("/gsubprocess/env/inherit", test_env_inherit);
g_test_add_func ("/gsubprocess/cwd", test_cwd);