Re: forking an external process
- From: Toby Gray <toby gray ntlworld com>
- To: Kim Schulz <kim schulz dk>
- Cc: gtk-perl-list gnome org
- Subject: Re: forking an external process
- Date: Tue, 7 May 2002 23:54:11 +0100
On Tuesday 07 May 2002 9:04 pm, you wrote:
hi
I want my gui to be accesable even when an external process is doing
some work.
My program does the following:
initialise the GUI
exec of a wget process
wait for it to return
do somthing to the return which will update the GUI (add rows to a
clist)
as it is now it hangs while the wget process is running. I have tried to
fork it but it doesnt work:
sub getnews{
$clist->clear();
if (fork() == 0) {
exec("wget http://www.slashdot.org/slashdot.rdf -nv -q -O \
slashdot.rdf");
exit(0);
}
parse_xml();
}
what have I done wrong? the parse_xml part is only to be runned when the
exec has returned somthing
As others have said all that is needed, I'll just add some problems you
probabley won't know about so get confused/worried/want to kill perl when you
come across them:
In any perl: forked processes become zombies after they die, and send a
SIGCHLD to the main process (I'm assuming unix as you are using wget) and you
have to reap your zombies, this is mentioned in the 'camel' book near
forking, so it should be easy to find more indepth information I would guess,
if you can't find any, mail me and I'll be happy to spend some time
explaining.
With GTK and perl you have to use _exit() to exit a fork, due to some complex
reason, otherwise you get some horrid errors about x libaries and you get all
confused (at least I did).
Toby
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]