in reply to Yet another spawn question. Portable method?

Welcome to the monastery

What is the question?

update

From the comments inside the code, it seems you're asking how to fork in an OS agnostic way.

On a side note:

With this chain strategy you are risking to run unlimited numbers of jobs in parallel .

Having one master controlling all slaves would give you better control.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re: Yet another spawn question. Portable method?

Replies are listed 'Best First'.
Re^2: Yet another spawn question. Portable method?
by MickeyLane (Initiate) on Sep 16, 2017 at 15:20 UTC

    My apologies for the missing question - updated.

    As for the chain, each time a script is started, an integer is passed as an arg that indicates how many times the script can be spawned. Each spawn decrements the int. "perl spawn.pl 3" will cause 3 instances of the script to be spawned:

    D:\Views Tests>perl spawn.pl 3 Starting PID 3616 as instance 3 Starting PID 5940 as instance 2 Starting PID 6064 as instance 1 PID 3616 ended D:\Views Tests>Starting PID 4564 as instance 0 PID 5940 ended PID 6064 ended PID 4564 ended
      > Each spawn decrements the int.

      Still, you are unnecessarily giving up control, like the possibility to kill the master and all children at the same time.

      see also perlipc

      This is not my field of expertise, but IMHO your requirement not to use extra modules will make this a rather complicated task.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!