* Boston, MA 02111-1307, USA.
*/
+#include <config.h>
+
#include "glib.h"
#include <sys/time.h>
#include <sys/types.h>
* should be a %NULL-terminated array of strings, to be passed as the
* argument vector for the child. The first string in @argv is of
* course the name of the program to execute. By default, the name of
- * the program must be a full path; the <envvar>PATH</envvar> shell variable
+ * the program must be a full path; the <envar>PATH</envar> shell variable
* will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag.
*
* @envp is a %NULL-terminated array of strings, where each string
* descriptors except stdin/stdout/stderr will be closed before
* calling <function>exec()</function> in the child. %G_SPAWN_SEARCH_PATH
* means that <literal>argv[0]</literal> need not be an absolute path, it
- * will be looked for in the user's <envvar>PATH</envvar>.
+ * will be looked for in the user's <envar>PATH</envar>.
* %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standad output will
* be discarded, instead of going to the same location as the parent's
* standard output.
* appropriate. Possible errors are those from g_spawn_sync() and those
* from g_shell_parse_argv().
*
+ * On Windows, please note the implications of g_shell_parse_argv()
+ * parsing @command_line. Space is a separator, and backslashes are
+ * special. Thus you cannot simply pass a @command_line consisting of
+ * a canonical Windows path, like "c:\\program files\\app\\app.exe",
+ * as the backslashes will be eaten, and the space will act as a
+ * separator. You need to enclose the path with single quotes, like
+ * "'c:\\program files\\app\\app.exe'".
+ *
* Return value: %TRUE on success, %FALSE if an error was set
**/
gboolean
* consider using g_spawn_async() directly if appropriate. Possible
* errors are those from g_shell_parse_argv() and g_spawn_async().
*
+ * The same concerns on Windows apply as for g_spawn_command_line_sync().
+ *
* Return value: %TRUE on success, %FALSE if error is set.
**/
gboolean
{
gchar **new_argv;
- new_argv = g_new0 (gchar*, argc + 1);
+ new_argv = g_new0 (gchar*, argc + 2); /* /bin/sh and NULL */
new_argv[0] = (char *) "/bin/sh";
new_argv[1] = (char *) file;
- while (argc > 1)
+ while (argc > 0)
{
- new_argv[argc] = argv[argc - 1];
+ new_argv[argc + 1] = argv[argc];
--argc;
}