Daryl,

  I appreciated the help.  But the perl code in the elsif statement
still doesn't execute until the perl code in the if statement.  

  Any other suggestions?  I'd like the two perl codes to execute at the
same time.
 
  Maybe fork can't do this..

THanks,
Chad


On Wed, 2002-11-13 at 15:40, Daryl J. Hoyt wrote:
> I think what you want is 
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> $SIG{CHLD} = sub {wait ()}; #wait to avoid zombies
> 
> my $pid = fork ();
> die "cannot fork: $!" unless defined($pid);
> if  ($pid == 0) {
>      #do some perl stuff
>    }
> elsif($pid < 0) {
>      #do some other perl stuff
>    exit(0);
> }
> waitpid($pid,0);
> 
> 
> Daryl J. Hoyt
> Software Engineer
> Geodesic Systems
> 312-832-2010
> < http://www.geodesic.com>
> < mailto:djh@;geodesic.com>
> 
> 
> 
> 
> -----Original Message-----
> From: chad kellerman [mailto:ckellerman@;alabanza.com]
> Sent: Wednesday, November 13, 2002 2:32 PM
> To: [EMAIL PROTECTED]
> Subject: fork?
> 
> 
> Hey guys,
> 
>      I maybe misunderstanding what a fork can do, so I thought I would
> write in to verify.  Because it doesn't appear to be doing what I want
> (think it should).
> 
> I have a script that tars (unix) directories.  I want the script to tar
> directories [a-n] as it is tarrring up [a-n] I want it to tar [o-z].  At
> the same time.  So that two tars would be running st the same time.
> 
>    what I did was
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> $SIG{CHLD} = sub {wait ()}; #wait to avoid zombies
> 
> my $pid = fork ();
> die "cannot fork: $!" unless defined($pid);
> if  ($pid == 0) {
>      #do some perl stuff
>    }
>    exit(0);
> }
> waitpid($pid,0);
> 
> #do some other perl stuff while above is running.
> 
> 
>   I want the perl script to "multi task".  
> 
> Am I missing something??
> 
> thanks,
> Chad
> 
> 
> 
> 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to