mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
GWin32AppInfo: Actually report the GPid in the GAppLaunchContext::launched signal
We need to pass the G_SPAWN_DO_NOT_REAP_CHILD flag to g_spawn_async, otherwise the returned child_pid will always be 0.
This commit is contained in:
parent
9bc9a9b62a
commit
45bdeeddff
@ -1439,6 +1439,11 @@ g_app_launch_context_class_init (GAppLaunchContextClass *klass)
|
||||
* example if the process was launched via D-Bus). The `pid` may not be
|
||||
* set at all in subsequent releases.
|
||||
*
|
||||
* On Windows, `pid` is guaranteed to be valid only for the duration of the
|
||||
* #GAppLaunchContext::launched signal emission; after the signal is emitted,
|
||||
* GLib will call g_spawn_close_pid(). If you need to keep the #GPid after the
|
||||
* signal has been emitted, then you can duplicate `pid` using `DuplicateHandle()`.
|
||||
*
|
||||
* Since: 2.36
|
||||
*/
|
||||
signals[LAUNCHED] = g_signal_new (I_("launched"),
|
||||
|
@ -4845,7 +4845,8 @@ g_win32_app_info_launch_internal (GWin32AppInfo *info,
|
||||
if (!g_spawn_async (NULL,
|
||||
argv,
|
||||
envp,
|
||||
spawn_flags,
|
||||
spawn_flags |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL,
|
||||
NULL,
|
||||
&pid,
|
||||
@ -4871,6 +4872,7 @@ g_win32_app_info_launch_internal (GWin32AppInfo *info,
|
||||
g_variant_unref (platform_data);
|
||||
}
|
||||
|
||||
g_spawn_close_pid (pid);
|
||||
g_strfreev (argv);
|
||||
argv = NULL;
|
||||
}
|
||||
|
@ -1417,6 +1417,9 @@ g_spawn_command_line_async (const gchar *command_line,
|
||||
void
|
||||
g_spawn_close_pid (GPid pid)
|
||||
{
|
||||
/* CRT functions such as _wspawn* return (HANDLE)-1
|
||||
* on failure, so check also for that value. */
|
||||
if (pid != NULL && pid != (HANDLE) -1)
|
||||
CloseHandle (pid);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user