in reply to Multiple forks get re-executed

Yes, you must write a tasksub like so
sub RUN { my$i;return$i||0if($i=fork)||!defined$i;die"\n"if"-".do #tasksub head { #your code here, you are forked already } }
If you comment the line beginning with my you have a normal sub (that should return undef btw). Don't make the die to exit, because there are Situations where it's needed.

Replies are listed 'Best First'.
Re: Re: Multiple forks get re-executed
by chromatic (Archbishop) on Jul 10, 2001 at 02:25 UTC
    Which Situations are those? Page 716 of Camel 3 states, in part:
    Be careful to end the child code with an exit...
    I'm not sure about the use of concatenation in the if, either. Do you often find yourself writing subroutines that may or may not need to fork?
      The situations are Resource-allocations in the parent (and caller) on behalf of the child, that the child must return to the pool on end, but wants to do in the caller because of lexical restrictions or clarity of writing.
      Do you often find yourself writing subroutines that may or may not need to fork?
      
      Of course in testing and debugging. Debugging a (multiply) forked sub is a PITA(TM).