Re: g_spawn_asnyc -- What is wrong ?
- From: Tristan Van Berkom <vantr touchtunes com>
- To: Harring Figueiredo <harringf yahoo com>
- Cc: gtk_list gtk gtk <gtk-app-devel-list gnome org>
- Subject: Re: g_spawn_asnyc -- What is wrong ?
- Date: Wed, 16 Oct 2002 13:20:34 -0400
try using:
g_shell_parse_argv()
(that will just do the argv setup for you)
and remember that
sprintf(text, "this and" "that");
will make text:
"this andthat"
where as
sprintf(text, "this and " "that");
will make:
"this and that"
so your cmd is actualy:
"/bin/rmhello.txt"
instead of:
"/bin/rm hello.txt"
BTW:
isn't "remove()" from stdio.h platform indepentend ?
(I'm not sure about opendir()/readdir() from dirent.h
but I think thats standard too.)
Harring Figueiredo wrote:
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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]