Glib, spawning processes & redirection



How do I redirect output(stdout) from a process spawned with one of the standard glib spawn functions to a file? I have managed to capture output in a gchar pointer, but if I try to do something with it, my app just segfaults.
Any solution is welcome.

Snippet on how I have managed to capture output included below:

      gchar *output;
      gchar *commandline;
      gchar *prefix2 = "Eterm -e wine ";
[...]
gchar * commandline = g_strjoin(NULL,prefix1, " disasm ", filename, NULL);
      gtk_progress_bar_set_text (progress, "Disasembling");
g_spawn_command_line_sync (commandline, &output, NULL, NULL, &myerror);

Filename is retrieved with filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));

Help needed!
I know how I would have done it in perl, but with glib & c I'm clueless.
I need to have it done in a cross platform frinedly matter too.
Putting > in commandline didn't help either.

     Jann -Ove Risvik



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