use Acme::Spork;

    print 1;
    spork(
        sub {
            sleep 5;
            print "child\n"
        },
    );
    print "parent\n";

and the standard:

    my $child = fork ();

    unless ($child) {
        sleep 5;
        print "child\n";
    }

    print "parent\n" if $child;

fork() only exhibits the behavior you describe if you issue a blocking
wait() or wait

Funny, I've always had trouble with fork()s making my browser run and run even thought the page was output Thats why I was so happy to discover Acme::Spork, I can spork before during and after the html output and the browser is done running as soon as the htmnl is out put. Plust it *spork*, how cool is that!

I'll play around with it a bit more. Thanks

What Acme::Spork does is simplify the logic a bit when you want to
fork multiple children to do different things. Since fork() creates
and exact duplicate of the running process, you end up writing a lot
of if block and setting a lot of flags to make your children behave
differently. Acme::Spork makes it easier to fork a child to execute a
specific bit of code by executing the fork from an external process
that contains nothing except your coderef and the few lines of the
Acme::Spork code itself. You pass it a coderef and let the module
write the if-else block for you.

This is very useful, particularly if you're spawning a lot of children
for a program with a large resident memory size, but it's just a
wrapper for fork().

It also uses POSIX's setsid. Which makes it a triffle different than fork().

Its actually the only way I've found to be able to start some loong running logging, setup verofier, process and output a webpagewithout the browser having to keep running.

Plus it does make it easier to code lots of sporks instead of linearly doing the if(fork() ... dance

Sorry for the mistyping, my mail client is wonky ...

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to