I have some program want to use Glib for cross-platform running. but I found Glib's process control g_spawn*() functions are very difficult to use. I don't know how to replace some very basic use of Unix system function fork().
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
pid_t pid = fork();
if (pid == 0)
{
printf("Here is child process\n");
}
else if (pid > 0)
{
printf("Here is parent process\n");
}
else
{
// fork failed
printf("fork() failed!\n");
return 1;
}
return 0;
}
the g_spawn*() functions description is here,It need fill a lot of arguments and even need other functions help it bind IO,I don't know how to use them replace fork(), it always try to run some scripts in "gchar **argv," argument. but I just need it work like fork(),don't want it run like exec(). Click here!