Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to make it so when I fork in the program, that the parent is not waiting for children to finish? I have a gui running which requests some things from the server. The things is that the connection to the server is very slow, so the gui is completely frozen why awaiting the connection. Is there a way that I can have the child processes do their thing with the server while the parent process is updating the gui? Thanks. P.S. I have a constraint of using Perl 5.8. Can't upgrade to 5.14 for technical reasons (if I could, I wouldn't be stuck).

Replies are listed 'Best First'.
Re: Forks (not waiting for children)
by ikegami (Patriarch) on Feb 07, 2012 at 21:38 UTC

    Is there a way to make it so when I fork in the program, that the parent is not waiting for children to finish?

    The parent doesn't wait for the children unless you make it.

Re: Forks (not waiting for children)
by zentara (Cardinal) on Feb 08, 2012 at 10:49 UTC
Re: Forks (not waiting for children)
by Anonymous Monk on Feb 07, 2012 at 21:42 UTC
    UPDATE: I had a slight mistake in the code, so now I can tell that the parent is not waiting. But it seems that the children didn't update any global variables. I figured that it is because everything they do can't be shared with the parent. Is there a way to share variables between processes? Thanks for the help.

      See perlipc, or use a database. The best approach to interaction with other processes is to avoid the interaction, or at least try to couple it as loose as possible, like having each child write the results to a separate file.

      Shared memory? Threads instead of forks? Use the event loop of your gui frame work? Use another form of communication between processes instead of a variable?

      Is this in relation to Fork Sharing Globals? If so, it would be helpful for us if you would link to the other question.

      --MidLifeXis

Re: Forks (not waiting for children)
by kielstirling (Scribe) on Feb 08, 2012 at 02:21 UTC
    Hi

    You need to use waitpid

    Read

    Kiel R Stirling