also i tried using this

my $child = fork ();

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

block of code, but i had a problem. Instead of the print statements,
i had 2 system calls one inside the block and one outside. Now,
as was expected, the fork allowed the one outside to get started.
But then a strange thing happened. After the fork process was finished,
the code re-executed the post system process, resulting in multiple, same
commands, which is obviously not what i wanted.

here is how it was:

        my $child = fork();
        unless($child) {
            system('oggenc','something something') == 0 or die "$?" ;
        }
    system('mencoder','something something') == 0 or die "system 'mencoder'
failed: $?" ;

Now what happened was. after oggenc finished, it again started mencoder.
resulting in
an undesirable mencoder process, creating a worse situation than original.

kindly tell me what to do.

thanks
Saurabh


On 3/10/06, Saurabh Singhvi <[EMAIL PROTECTED]> wrote:
>
> i got the following error while trying to install spork
>
> Checking if your kit is complete...
> Looks good
> Warning: prerequisite version 0 not found.
> Could not eval '
>             package ExtUtils::MakeMaker::_version;
>             no strict;
>
>             local $VERSION;
>             $VERSION=undef; do {
>                 use version;our $VERSION = qv('0.0.3');
>             }; $VERSION
>         ' in lib/Acme/Spork.pm: Can't locate version.pm in @INC (@INC
> contains: /etc/perl /usr/lib/perl5/site_perl/5.8.7/i686-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6
> /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.7/i686-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6
> /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.7/i686-linux-thread-multi
> /usr/lib/perl5/5.8.7 /usr/local/lib/site_perl .) at (eval 7) line 7, <FH>
> line 12.
> BEGIN failed--compilation aborted at (eval 7) line 7, <FH> line 12.
> WARNING: Setting VERSION via file 'lib/Acme/Spork.pm' failed
>  at /usr/lib/perl5/5.8.7/ExtUtils/MakeMaker.pm line 495
> Writing Makefile for Acme::Spork
>
> it'd be a gr8 help if som1 could tell me what was wrong.
>
> thanks
> Saurabh
>
> On 3/7/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote:
> >
> > >    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