support G_SPAWN_FILE_AND_ARGV_ZERO specifying that the vector passed in to
authorHavoc Pennington <hp@redhat.com>
Fri, 8 Jun 2001 19:41:51 +0000 (19:41 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Fri, 8 Jun 2001 19:41:51 +0000 (19:41 +0000)
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.

14 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/glib/tmpl/macros_misc.sgml
docs/reference/glib/tmpl/spawn.sgml
glib/gspawn.c
glib/gspawn.h
gspawn.c
gspawn.h

index 7806219..006ab4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7806219..006ab4b 100644 (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>
 
        * configure.in: Added Azeri (az) to ALL_LINGUAS
index 7b93d0a..cd71ee7 100644 (file)
@@ -71,6 +71,7 @@ arrays or arrays on the stack.
 Portable way to copy <type>va_list</type> variables.
 </para>
 
+<!-- # Unused Parameters # -->
 @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
 @ap2: a <type>va_list</type>.
 
index 3cf178f..358cce6 100644 (file)
@@ -58,6 +58,7 @@ Spawning Processes (fork/exec)
 @G_SPAWN_STDOUT_TO_DEV_NULL: 
 @G_SPAWN_STDERR_TO_DEV_NULL: 
 @G_SPAWN_CHILD_INHERITS_STDIN: 
+@G_SPAWN_FILE_AND_ARGV_ZERO: 
 
 <!-- ##### USER_FUNCTION GSpawnChildSetupFunc ##### -->
 <para>
index c8208f6..fd40617 100644 (file)
@@ -52,6 +52,7 @@ static gboolean fork_exec_with_pipes (gboolean              intermediate_child,
                                       gboolean              stdout_to_null,
                                       gboolean              stderr_to_null,
                                       gboolean              child_inherits_stdin,
+                                      gboolean              file_and_argv_zero,
                                       GSpawnChildSetupFunc  child_setup,
                                       gpointer              user_data,
                                       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_STDERR_TO_DEV_NULL) != 0,
                              (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
+                             (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
                              child_setup,
                              user_data,
                              &pid,
@@ -442,6 +444,11 @@ g_spawn_sync (const gchar          *working_directory,
  * will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that
  * the child will inherit the parent's standard input (by default,
  * 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
  * 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_STDERR_TO_DEV_NULL) != 0,
                                (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
+                               (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
                                child_setup,
                                user_data,
                                child_pid,
@@ -764,6 +772,7 @@ do_exec (gint                  child_err_report_fd,
          gboolean              stdout_to_null,
          gboolean              stderr_to_null,
          gboolean              child_inherits_stdin,
+         gboolean              file_and_argv_zero,
          GSpawnChildSetupFunc  child_setup,
          gpointer              user_data)
 {
@@ -854,7 +863,9 @@ do_exec (gint                  child_err_report_fd,
       (* 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 */
   write_err_and_exit (child_err_report_fd,
@@ -923,6 +934,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                       gboolean              stdout_to_null,
                       gboolean              stderr_to_null,
                       gboolean              child_inherits_stdin,
+                      gboolean              file_and_argv_zero,
                       GSpawnChildSetupFunc  child_setup,
                       gpointer              user_data,
                       gint                 *child_pid,
@@ -1021,6 +1033,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                        stdout_to_null,
                        stderr_to_null,
                        child_inherits_stdin,
+                       file_and_argv_zero,
                        child_setup,
                        user_data);
             }
@@ -1049,6 +1062,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                    stdout_to_null,
                    stderr_to_null,
                    child_inherits_stdin,
+                   file_and_argv_zero,
                    child_setup,
                    user_data);
         }
index 57530cb..dcebc3a 100644 (file)
@@ -59,13 +59,14 @@ typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
 typedef enum
 {
   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() */
-  G_SPAWN_SEARCH_PATH = 1 << 2,
+  G_SPAWN_SEARCH_PATH            = 1 << 2,
   /* Dump output to /dev/null */
-  G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
-  G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
-  G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5
+  G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
+  G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
+  G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
+  G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
 } GSpawnFlags;
 
 GQuark g_spawn_error_quark (void);
index c8208f6..fd40617 100644 (file)
--- a/gspawn.c
+++ b/gspawn.c
@@ -52,6 +52,7 @@ static gboolean fork_exec_with_pipes (gboolean              intermediate_child,
                                       gboolean              stdout_to_null,
                                       gboolean              stderr_to_null,
                                       gboolean              child_inherits_stdin,
+                                      gboolean              file_and_argv_zero,
                                       GSpawnChildSetupFunc  child_setup,
                                       gpointer              user_data,
                                       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_STDERR_TO_DEV_NULL) != 0,
                              (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
+                             (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
                              child_setup,
                              user_data,
                              &pid,
@@ -442,6 +444,11 @@ g_spawn_sync (const gchar          *working_directory,
  * will be discarded. %G_SPAWN_CHILD_INHERITS_STDIN means that
  * the child will inherit the parent's standard input (by default,
  * 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
  * 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_STDERR_TO_DEV_NULL) != 0,
                                (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
+                               (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
                                child_setup,
                                user_data,
                                child_pid,
@@ -764,6 +772,7 @@ do_exec (gint                  child_err_report_fd,
          gboolean              stdout_to_null,
          gboolean              stderr_to_null,
          gboolean              child_inherits_stdin,
+         gboolean              file_and_argv_zero,
          GSpawnChildSetupFunc  child_setup,
          gpointer              user_data)
 {
@@ -854,7 +863,9 @@ do_exec (gint                  child_err_report_fd,
       (* 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 */
   write_err_and_exit (child_err_report_fd,
@@ -923,6 +934,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                       gboolean              stdout_to_null,
                       gboolean              stderr_to_null,
                       gboolean              child_inherits_stdin,
+                      gboolean              file_and_argv_zero,
                       GSpawnChildSetupFunc  child_setup,
                       gpointer              user_data,
                       gint                 *child_pid,
@@ -1021,6 +1033,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                        stdout_to_null,
                        stderr_to_null,
                        child_inherits_stdin,
+                       file_and_argv_zero,
                        child_setup,
                        user_data);
             }
@@ -1049,6 +1062,7 @@ fork_exec_with_pipes (gboolean              intermediate_child,
                    stdout_to_null,
                    stderr_to_null,
                    child_inherits_stdin,
+                   file_and_argv_zero,
                    child_setup,
                    user_data);
         }
index 57530cb..dcebc3a 100644 (file)
--- a/gspawn.h
+++ b/gspawn.h
@@ -59,13 +59,14 @@ typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
 typedef enum
 {
   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() */
-  G_SPAWN_SEARCH_PATH = 1 << 2,
+  G_SPAWN_SEARCH_PATH            = 1 << 2,
   /* Dump output to /dev/null */
-  G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
-  G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
-  G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5
+  G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
+  G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
+  G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
+  G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
 } GSpawnFlags;
 
 GQuark g_spawn_error_quark (void);