Bug in g_spawn_sync: win32 vs linux



I have an application that spawns another app. I use g_spawn_sync. The first
argument is the process name. On Linux this argument seems to be removed, on
windows, its not. Consequently, my argument processor breaks; it skips the
first argument and starts at slot [1]. My current work around is to list the
process argument twice; occupies argv[0] and argv[1]; which seems to work.
Here's a code snippet of what I'm doing: (GTK 2.2.4, GLIB 2.2.3)

        gchar *argv[16];
        gint i=0;

            argv[i++] = gen_predict_exe;
#ifdef G_OS_UNIX
            /* unix removes the first arg???, windows leaves it??? */
            argv[i++] = gen_predict_exe;
#endif
            argv[i++] = "-start";
            argv[i++] = startTime;
            argv[i++] = "-stop";
            argv[i++] = stopTime;
            argv[i++] = "-config";
            argv[i++] = CP_GetConfigFilename();
            argv[i++] = NULL; 
            if (g_spawn_sync(NULL, argv, NULL,
                             (GSpawnFlags)(G_SPAWN_SEARCH_PATH |
G_SPAWN_FILE_AND_ARGV_ZERO),
                             NULL, NULL, NULL, NULL, &exit_status, &err)
                == FALSE)
        {
                // do error processing
        }
        ...

I'm not sure if the GSpawnFlags is causing the problem, but it does seem
like the behavior of g_spawn_sync should be the same regardless of platform!

Thanks,
Bruce



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]