support G_SPAWN_FILE_AND_ARGV_ZERO specifying that the vector passed in to

2001-06-08  Havoc Pennington  <hp@redhat.com>

	* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
	the vector passed in to g_spawn_* contains a filename to
	execute in argv[0] then the actual argv begins at argv + 1.
	Kind of a lame hack, but this isn't something you commonly want
	to do, and avoids adding more function arguments.
This commit is contained in:
Havoc Pennington
2001-06-08 19:41:51 +00:00
committed by Havoc Pennington
parent 78273842cc
commit 6858b5342f
14 changed files with 108 additions and 12 deletions

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -1,3 +1,11 @@
2001-06-08 Havoc Pennington <hp@redhat.com>
* gspawn.c: support G_SPAWN_FILE_AND_ARGV_ZERO specifying that
the vector passed in to g_spawn_* contains a filename to
execute in argv[0] then the actual argv begins at argv + 1.
Kind of a lame hack, but this isn't something you commonly want
to do, and avoids adding more function arguments.
2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com> 2001-06-08 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Azeri (az) to ALL_LINGUAS * configure.in: Added Azeri (az) to ALL_LINGUAS

View File

@@ -71,6 +71,7 @@ arrays or arrays on the stack.
Portable way to copy <type>va_list</type> variables. Portable way to copy <type>va_list</type> variables.
</para> </para>
<!-- # Unused Parameters # -->
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in. @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
@ap2: a <type>va_list</type>. @ap2: a <type>va_list</type>.

View File

@@ -58,6 +58,7 @@ Spawning Processes (fork/exec)
@G_SPAWN_STDOUT_TO_DEV_NULL: @G_SPAWN_STDOUT_TO_DEV_NULL:
@G_SPAWN_STDERR_TO_DEV_NULL: @G_SPAWN_STDERR_TO_DEV_NULL:
@G_SPAWN_CHILD_INHERITS_STDIN: @G_SPAWN_CHILD_INHERITS_STDIN:
@G_SPAWN_FILE_AND_ARGV_ZERO:
<!-- ##### USER_FUNCTION GSpawnChildSetupFunc ##### --> <!-- ##### USER_FUNCTION GSpawnChildSetupFunc ##### -->
<para> <para>

View File

@@ -52,6 +52,7 @@ static gboolean fork_exec_with_pipes (gboolean intermediate_child,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data, gpointer user_data,
gint *child_pid, gint *child_pid,
@@ -237,6 +238,7 @@ g_spawn_sync (const gchar *working_directory,
(flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0,
(flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0,
(flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
(flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
child_setup, child_setup,
user_data, user_data,
&pid, &pid,
@@ -442,6 +444,11 @@ g_spawn_sync (const gchar *working_directory,
* will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that * will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that
* the child will inherit the parent's standard input (by default, * the child will inherit the parent's standard input (by default,
* the child's standard input is attached to /dev/null). * the child's standard input is attached to /dev/null).
* %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
* the file to execute, while the remaining elements are the
* actual argument vector to pass to the file. Normally
* g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
* passes all of @argv to the child.
* *
* @child_setup and @user_data are a function and user data to be * @child_setup and @user_data are a function and user data to be
* called in the child after GLib has performed all the setup it plans * called in the child after GLib has performed all the setup it plans
@@ -504,6 +511,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
(flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0,
(flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0,
(flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
(flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
child_setup, child_setup,
user_data, user_data,
child_pid, child_pid,
@@ -764,6 +772,7 @@ do_exec (gint child_err_report_fd,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data) gpointer user_data)
{ {
@@ -854,7 +863,9 @@ do_exec (gint child_err_report_fd,
(* child_setup) (user_data); (* child_setup) (user_data);
} }
g_execute (argv[0], argv, envp, search_path); g_execute (argv[0],
file_and_argv_zero ? argv + 1 : argv,
envp, search_path);
/* Exec failed */ /* Exec failed */
write_err_and_exit (child_err_report_fd, write_err_and_exit (child_err_report_fd,
@@ -923,6 +934,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data, gpointer user_data,
gint *child_pid, gint *child_pid,
@@ -1021,6 +1033,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
stdout_to_null, stdout_to_null,
stderr_to_null, stderr_to_null,
child_inherits_stdin, child_inherits_stdin,
file_and_argv_zero,
child_setup, child_setup,
user_data); user_data);
} }
@@ -1049,6 +1062,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
stdout_to_null, stdout_to_null,
stderr_to_null, stderr_to_null,
child_inherits_stdin, child_inherits_stdin,
file_and_argv_zero,
child_setup, child_setup,
user_data); user_data);
} }

View File

@@ -59,13 +59,14 @@ typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
typedef enum typedef enum
{ {
G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
/* look for argv[0] in the path i.e. use execvp() */ /* look for argv[0] in the path i.e. use execvp() */
G_SPAWN_SEARCH_PATH = 1 << 2, G_SPAWN_SEARCH_PATH = 1 << 2,
/* Dump output to /dev/null */ /* Dump output to /dev/null */
G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5 G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
} GSpawnFlags; } GSpawnFlags;
GQuark g_spawn_error_quark (void); GQuark g_spawn_error_quark (void);

View File

@@ -52,6 +52,7 @@ static gboolean fork_exec_with_pipes (gboolean intermediate_child,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data, gpointer user_data,
gint *child_pid, gint *child_pid,
@@ -237,6 +238,7 @@ g_spawn_sync (const gchar *working_directory,
(flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0,
(flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0,
(flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
(flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
child_setup, child_setup,
user_data, user_data,
&pid, &pid,
@@ -442,6 +444,11 @@ g_spawn_sync (const gchar *working_directory,
* will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that * will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that
* the child will inherit the parent's standard input (by default, * the child will inherit the parent's standard input (by default,
* the child's standard input is attached to /dev/null). * the child's standard input is attached to /dev/null).
* %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
* the file to execute, while the remaining elements are the
* actual argument vector to pass to the file. Normally
* g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
* passes all of @argv to the child.
* *
* @child_setup and @user_data are a function and user data to be * @child_setup and @user_data are a function and user data to be
* called in the child after GLib has performed all the setup it plans * called in the child after GLib has performed all the setup it plans
@@ -504,6 +511,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
(flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0,
(flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0,
(flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
(flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
child_setup, child_setup,
user_data, user_data,
child_pid, child_pid,
@@ -764,6 +772,7 @@ do_exec (gint child_err_report_fd,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data) gpointer user_data)
{ {
@@ -854,7 +863,9 @@ do_exec (gint child_err_report_fd,
(* child_setup) (user_data); (* child_setup) (user_data);
} }
g_execute (argv[0], argv, envp, search_path); g_execute (argv[0],
file_and_argv_zero ? argv + 1 : argv,
envp, search_path);
/* Exec failed */ /* Exec failed */
write_err_and_exit (child_err_report_fd, write_err_and_exit (child_err_report_fd,
@@ -923,6 +934,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
gboolean stdout_to_null, gboolean stdout_to_null,
gboolean stderr_to_null, gboolean stderr_to_null,
gboolean child_inherits_stdin, gboolean child_inherits_stdin,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup, GSpawnChildSetupFunc child_setup,
gpointer user_data, gpointer user_data,
gint *child_pid, gint *child_pid,
@@ -1021,6 +1033,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
stdout_to_null, stdout_to_null,
stderr_to_null, stderr_to_null,
child_inherits_stdin, child_inherits_stdin,
file_and_argv_zero,
child_setup, child_setup,
user_data); user_data);
} }
@@ -1049,6 +1062,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
stdout_to_null, stdout_to_null,
stderr_to_null, stderr_to_null,
child_inherits_stdin, child_inherits_stdin,
file_and_argv_zero,
child_setup, child_setup,
user_data); user_data);
} }

View File

@@ -59,13 +59,14 @@ typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
typedef enum typedef enum
{ {
G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
/* look for argv[0] in the path i.e. use execvp() */ /* look for argv[0] in the path i.e. use execvp() */
G_SPAWN_SEARCH_PATH = 1 << 2, G_SPAWN_SEARCH_PATH = 1 << 2,
/* Dump output to /dev/null */ /* Dump output to /dev/null */
G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5 G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
} GSpawnFlags; } GSpawnFlags;
GQuark g_spawn_error_quark (void); GQuark g_spawn_error_quark (void);