However, the "it works like Unix" way is what the OP wants.

Actually, I disagree with your reading of the OP's question there. S/he asked for a cross platform solution to starting an asynchronous process.

Using fork and exec is one way of acheiving this, at least under unix, but it isn't the only way.

I realise that portability isn't an issue for you, but as it seems to be for the OP, then he might be better off using

system('command &'); on unix and

system('start command'); on Win32

And whatever the equivalent one-liner would be on his VMS systems, as the near-symmetry of the solutions on the different platforms would be much easier to manage than using the fork and exec model on unix and something different on the others.

The problem arises because of the need to try and emulate a perl behaviour that derives directly from a unix system behaviour that simply doesn't exist in the other platforms. AS have done a pretty good job of the emulation under Win32, and it works well enough for many purposes, but not all.

However, the lack of this unix feature in Win32 does not mean that Win32 is lacking the required facility--in this case the ability to start one asynchronous process from another--it just acheives it in a different, and one could say, more direct way.

Ie.

CreateProcess(command, ASYNCH); # done

as opposed to

newProc = CreateProcess(); CopyDataSegs(thisProc, newProc); newProc(command); BlowAwayCode&Data(); OverlayCodeFrom(command);

That doesn't mean its better or worse, just different. Hence the question about VMS and s390. Which of the two models do they more closely resemble? Or do they have a third model? How good is the fork and exec model supported on those platforms.

Using the system( 'start command' ); to start an asynchronous process actually comes down to remarkably similar set of steps as is used in the fork and exec model, and is neither hugely more or less efficient.

The problem arises because perl mirrors the underlying unix system calls so closely, which makes porting it to any non-unix system difficult.That's not a critisism of either unix nor perl. Just a statement of fact. Had unix had a createProcessAsynch() system call rather than relying on the fork and exec model, the porting problems to other systems would have been simpler.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

In reply to Re: Re: spawning Perl scripts by BrowserUk
in thread spawning Perl scripts by awkmonk

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.