gtk - How to use Glib g_spawn*() functions replace fork() -


i have program want use glib cross-platform running. found glib's process control g_spawn*() functions difficult use. don't know how replace 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 child process\n");      }      else if (pid > 0)      {          printf("here parent process\n");      }      else      {          // fork failed          printf("fork() failed!\n");          return 1;      }      return 0;  }

the g_spawn*() functions description here,it need fill lot of arguments , need other functions bind io,i don't know how use them replace fork(), try run scripts in "gchar **argv," argument. need work fork(),don't want run exec(). click here!

the process spawning api in glib designed replace common pattern of using fork() , exec() together, not fork(). it's nice (and easy) designed for, if want api acts fork() should use fork().


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -