Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Launching numerous instances of the same program

by Zombie Terrabyte (Initiate)
on Jan 11, 2001 at 01:51 UTC ( #50990=categorized question: print w/replies, xml ) Need Help??
Contributed by Zombie Terrabyte on Jan 11, 2001 at 01:51 UTC
Q&A  > programs and processes


How can I launch many instances of the same program from within a perl script. An example would be starting 10 instances of calc on the Win32 platform. When I use system, it waits for a response. When I use exec, it shifts to calc. If I fork, I just start myself again. Help!!!!

Answer: Launching numerous instances of the same program
contributed by extremely

Fork 10 children and exec calc in the children. Also, FYI a fork in a loop is called a fork-bomb. Make sure you know exactly how your loop works so that you don't consume all the allowed resources under your OS and kill the box. I've personally seen a 1/4 million dollar machine rebooted more than once over other goofballs doing this. People loose root access, their jobs, or get the FBI called on them for tricks of this sort. =)

Answer: Launching numerous instances of the same program
contributed by repson

On a win32 system you will want create processes with Win32::Process in a loop. A fork and exec will not work in windows.

Answer: Launching numerous instances of the same program
contributed by turnstep

Don't expect fork to work very well under Win32 either...see the thread fork on Win32

Answer: Launching numerous instances of the same program
contributed by jplindstrom

I personally like the Win32::Process module, but another way of doing this (the Windows way of starting things with &) is to use the "start" command.

Type "start /?" at the command line to get the options.


Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [ambrus]: 1nickt: the tea didn't have sugar or honey or lemon or milk. or even caffeine in a significant quantity. it's really "colored water", warm water with some fruit smell to make it more pleasant than ordinary warm water.
    [ambrus]: 1nickt: in theory, it shouldn't hurt the electronics, but also could temporarily cause problems until it dries, and the inside of the keyboard doesn't dry quickly, because it's closed.
    [ambrus]: 1nickt: that's the theory. the theory is also that it should have dried by Sunday morning, but it didn't. so I dunno.
    [ambrus]: I'll try today evening if it works now.

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (11)
    As of 2017-11-21 14:39 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (302 votes). Check out past polls.