g_spawn_asnyc -- What is wrong ?




 Hello all,

 I am trying to use g_spawn_async, but so far I am not getting the results I
expect.

  In the program below: 
  1) The output from the func() is never displayed.
  2) The file hello.txt is never removed.
  3) I get the child's pid correctly (i.e, not 0 or -1)
  4) The program does not report errors.


   I am sure I am doing something really wrong -- where ?

  Note: I am trying to do this so that I can delete a directory recursively in
windoze and Linux, so I am trying to stay platform independent by using this -
Any better alternatives ?

   Thanks in advance.
  

=== Program ==========

void func(gpointer data) { 
g_print("Executed child func ...");
}

int deltree(const char* path)
{
   char* cmd[] = { "/bin/rm" "hello.txt", "NULL"};
   gint pid = 0;
   GError* err = NULL;
   gboolean ret_val;
    GSpawnChildSetupFunc  func;

   ret_val = g_spawn_async_with_pipes(NULL,cmd ,NULL,
           G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_SEARCH_PATH, func, NULL,
           &pid, NULL, NULL, NULL, &err);
   if(ret_val != TRUE)
       g_print("Failed..\n");
   else
       g_print("Did not fail.\n");

   if(err) g_print("Error: %s\n" , err->message);
   g_print("Child PID: %d\n" , pid);

   g_print (" Done...\n");
   return 0;
}

int main()
{
    deltree("path");
    return 0;
}


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



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