mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-30 20:33:08 +02:00
Merge branch 'close_subprocess_parent_fds_on_dispose' into 'master'
GSubprocessLauncher: Move cleanup to dispose() See merge request GNOME/glib!1670
This commit is contained in:
commit
1538a89b11
@ -131,47 +131,52 @@ g_subprocess_launcher_set_property (GObject *object, guint prop_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_subprocess_launcher_finalize (GObject *object)
|
g_subprocess_launcher_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
GSubprocessLauncher *self = G_SUBPROCESS_LAUNCHER (object);
|
GSubprocessLauncher *self = G_SUBPROCESS_LAUNCHER (object);
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_free (self->stdin_path);
|
g_clear_pointer (&self->stdin_path, g_free);
|
||||||
g_free (self->stdout_path);
|
g_clear_pointer (&self->stdout_path, g_free);
|
||||||
g_free (self->stderr_path);
|
g_clear_pointer (&self->stderr_path, g_free);
|
||||||
|
|
||||||
if (self->stdin_fd != -1)
|
if (self->stdin_fd != -1)
|
||||||
close (self->stdin_fd);
|
close (self->stdin_fd);
|
||||||
|
self->stdin_fd = -1;
|
||||||
|
|
||||||
if (self->stdout_fd != -1)
|
if (self->stdout_fd != -1)
|
||||||
close (self->stdout_fd);
|
close (self->stdout_fd);
|
||||||
|
self->stdout_fd = -1;
|
||||||
|
|
||||||
if (self->stderr_fd != -1)
|
if (self->stderr_fd != -1)
|
||||||
close (self->stderr_fd);
|
close (self->stderr_fd);
|
||||||
|
self->stderr_fd = -1;
|
||||||
|
|
||||||
if (self->basic_fd_assignments)
|
if (self->basic_fd_assignments)
|
||||||
{
|
{
|
||||||
for (i = 0; i < self->basic_fd_assignments->len; i++)
|
for (i = 0; i < self->basic_fd_assignments->len; i++)
|
||||||
(void) close (g_array_index (self->basic_fd_assignments, int, i));
|
(void) close (g_array_index (self->basic_fd_assignments, int, i));
|
||||||
g_array_unref (self->basic_fd_assignments);
|
g_clear_pointer (&self->basic_fd_assignments, g_array_unref);
|
||||||
}
|
}
|
||||||
if (self->needdup_fd_assignments)
|
if (self->needdup_fd_assignments)
|
||||||
{
|
{
|
||||||
for (i = 0; i < self->needdup_fd_assignments->len; i += 2)
|
for (i = 0; i < self->needdup_fd_assignments->len; i += 2)
|
||||||
(void) close (g_array_index (self->needdup_fd_assignments, int, i));
|
(void) close (g_array_index (self->needdup_fd_assignments, int, i));
|
||||||
g_array_unref (self->needdup_fd_assignments);
|
g_clear_pointer (&self->needdup_fd_assignments, g_array_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->child_setup_destroy_notify)
|
if (self->child_setup_destroy_notify)
|
||||||
(* self->child_setup_destroy_notify) (self->child_setup_user_data);
|
(* self->child_setup_destroy_notify) (self->child_setup_user_data);
|
||||||
|
self->child_setup_destroy_notify = NULL;
|
||||||
|
self->child_setup_user_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_strfreev (self->envp);
|
g_clear_pointer (&self->envp, g_strfreev);
|
||||||
g_free (self->cwd);
|
g_clear_pointer (&self->cwd, g_free);
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_subprocess_launcher_parent_class)->finalize (object);
|
G_OBJECT_CLASS (g_subprocess_launcher_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -194,7 +199,7 @@ g_subprocess_launcher_class_init (GSubprocessLauncherClass *class)
|
|||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
gobject_class->set_property = g_subprocess_launcher_set_property;
|
gobject_class->set_property = g_subprocess_launcher_set_property;
|
||||||
gobject_class->finalize = g_subprocess_launcher_finalize;
|
gobject_class->dispose = g_subprocess_launcher_dispose;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, 1,
|
g_object_class_install_property (gobject_class, 1,
|
||||||
g_param_spec_flags ("flags", "Flags", "GSubprocessFlags for launched processes",
|
g_param_spec_flags ("flags", "Flags", "GSubprocessFlags for launched processes",
|
||||||
@ -634,12 +639,16 @@ g_subprocess_launcher_take_fd (GSubprocessLauncher *self,
|
|||||||
{
|
{
|
||||||
if (source_fd == target_fd)
|
if (source_fd == target_fd)
|
||||||
{
|
{
|
||||||
g_array_append_val (self->basic_fd_assignments, source_fd);
|
if (self->basic_fd_assignments)
|
||||||
|
g_array_append_val (self->basic_fd_assignments, source_fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_array_append_val (self->needdup_fd_assignments, source_fd);
|
if (self->needdup_fd_assignments)
|
||||||
g_array_append_val (self->needdup_fd_assignments, target_fd);
|
{
|
||||||
|
g_array_append_val (self->needdup_fd_assignments, source_fd);
|
||||||
|
g_array_append_val (self->needdup_fd_assignments, target_fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user