Well first of all congrats to your first posting! It would be easier to read if you'use html tags to format your post. See also the Site How To.

To your questions: It is possible to run 4 scripts simultanously by using the fork function. Ifyou are running a unix like OS this should work, i don't know about windows systems though.
Back to fork -- er work: The fork function will create a new process and return the process id of the created process - known as child process. The Camel Book states the safest way to check fork for errors:

FORK: { if ($pid == fork){ #deal with the parent process #pid of child is stored in $pid }elsif (defined $pid){ #handling child process #parent pid is available via the getppid function }elsif ($! =~/No more processes/){ # EAGAIN, this error we should be able to fix sleep 5; redo FORK; } else { #this should'nt happen at all die "cannot execute fork: $!\n"; }

Don't forget to do a reset on all your open buffers with setting $|. To avoid Zombies you should wait for your childs to exit. Use always the exit() function to end a process! The function used to wait for a child is as you may have guessed wait wait will wait and return whenever a child process exits. The status of the process is then stored in $? and the return value represents the process id of the exiting child process. If there is no child process at al you will get a -1 back. Another way to avoid Zombies is to install a Signal handler that will take care of you SIGCHLD signals: $SIG{CHLD} = sub(wait);

I hope this is enough to get you going. For reference use perldoc -f fork and perldoc -f wait.

Regards,
C-Keen

Edit by tye


In reply to Running more than one process (the very basics) by C-Keen
in thread Reminder program by bsdbudha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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, details, 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, summary, 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.