All but the last two wait for the exe to finish before completing the script ...

You're misinterpreting the symptoms.

  1. system 1, ... will return to your script immediately.

    The waiting occurs within the web server itself. Here's why.

    When a webserver starts a cgi script, it supplies (via inheritance) that script with it standard handles: stdin; stdout; and stderr. It then waits for those handles to close before it transmits the output from the script to the browser.

    But when you call system 1, ... within the cgi, that child process inherits its standard handles from the cgi script. So, even though your script finishes and perl.exe exits, the standard handles it inherited are still being held open by the new process. So the webserver continues to wait until those handles are closed, which won't be until that new process (MedicaidEHRService.exe) completes.

  2. exec .... Ditto. The process that replaces perl.exe will inherit the standard handles; the webserver waits.
  3. exec "start ...". Ditto again.

    Might work if you added the /b parameter to the start command.

  4. Win32::Process::Create( .... Will probably work once you pass DETACHED_PROCESS correctly.
  5. With the last two, the standard handles are closed, so the webserver detects eof and completes the transaction.

    But, and I can only speculate here as I don't have that particular executable, the program you are running must need the one or more of the standard handles for some reason to work correctly, and fails because they are closed.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Running detached processes with Activeperl under IIS by BrowserUk
in thread Running detached processes with Activeperl under IIS by Jules

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.