system and exec are doing what they ought to do. system runs an external program and returns when it exits. exec replaces the current process with another process.

Your title suggests fork but you don't actually use it in this code. On Unix, the idiom would be to fork the program and, in the child, exec the other program you want to run. When you do this, the parent continues as it is and the child immediately replaces itself with the other process.

You can get more complex if you need to do so -- and you may, on Windows, with something like the Win32 module and CreateProcess -- but I think you may have misunderstood that there are three different ideas here and just what the differences are between them.


In reply to Re: MS Forking Blues by chromatic
in thread MS Forking Blues by Dru

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.