Fix process spawning with static build on Windows

On Windows, process spawning needs an external helper exe which is found
relatively to the glib DLL file. If glib has been built statically this
file doesn't exist anymore and reference path is not the DLL path
anymore but the current executable path.

This patch searches for the helper exe taking as starting point the
current executable path, relative 'bin', 'lib', 'glib' and 'gio' folders
and then gets one level up until the root path. If this search doesn't
give result then the helper exe is searched using the PATH variable.
This commit is contained in:
Loic Le Page
2022-01-05 18:06:01 +01:00
parent 94f4ec85c6
commit 41f8bbd02d
6 changed files with 130 additions and 54 deletions

View File

@@ -120,7 +120,6 @@ gboolean g_check_setuid (void);
GMainContext * g_main_context_new_with_next_id (guint next_id);
#ifdef G_OS_WIN32
gchar *_glib_get_dll_directory (void);
GLIB_AVAILABLE_IN_ALL
gchar *_glib_get_locale_dir (void);
#endif
@@ -168,6 +167,10 @@ typedef struct {
int (* g_win32_fstat) (int fd,
GWin32PrivateStat *buf);
/* See gwin32.c */
gchar *(*g_win32_find_helper_executable_path) (const gchar *process_name,
void *dll_handle);
#endif