As far as I know, the exec command does not launch the argument program in background mode. It launches the program in the foreground and never returns to the Perl program. But the Perl program really appears to end when the argument program completes. This is an example on Unix of an exec command taking a bit of time to execute:
$ time perl -e 'print "start program. \n"; exec ("time ls -lR /usr | w +c");' start program. 36311 269214 1917392 real 0m8.933s user 0m1.309s sys 0m3.883s real 0m9.012s user 0m1.339s sys 0m3.929s
The command passed to exec is counting all the files in the /usr directory and all its subdirectories. It takes a bit of time since there are more than 36000 entries. Under Unix, the time program measures the execution time. The first report states the time taken by the exec command. The second one gives the time taken by the Perl program. As you can see, the Perl program completed only after the exec command finished. No background process here. Under Unix, I could launch my command in the background this way:
$ time perl -e 'print "start program. \n"; exec ("time ls -lR /usr | w +c &");' start program. real 0m0.090s user 0m0.045s sys 0m0.030s Laurent ~ $ 36311 269214 1917392 real 0m4.102s user 0m1.200s sys 0m2.963s
Here, the exec command is really launched in the background and the Perl program completes immediately (after 0.09 sec.) and the exec command prints the result and completes 4 seconds later. I do not know how you would do that under Windows, but you might have to launch an intermediate xxx.bat script that launches the background process and exits immediately.

In reply to Re: Capture HTTP Error CGI Perl by Laurent_R
in thread Windows Background forking in Perl /HTTP Error Capture by suzun30

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.