I need to know if there is a solution to exec() acting differently on windows vs unix. Best way to see the difference is using 3 little perl scripts (I'm displaying them from unix with the "more" command, but they will run as-is on windows also)
-> more testexec* :::::::::::::: testexec.pl :::::::::::::: #!/usr/bin/perl system("testexec2.pl"); print "Done $0\n"; :::::::::::::: testexec2.pl :::::::::::::: #!/usr/bin/perl exec($^X,"testexec3.pl") or print "exec failed - $!\n"; print "Done $0\n"; :::::::::::::: testexec3.pl :::::::::::::: #!/usr/bin/perl `sleep 3`; print "Done $0\n";
On unix, things act as expected: testexec.pl waits for testexec2.pl to finish (with testexec2.pl being replaced with testexec3.pl). But on windows, testexec.pl does NOT wait for testexec2.pl/testexec3.pl to finish. Is there a way to get Windows to act the same as unix? The windows behaviour does not seem correct...

FYI: I'm trying to avoid using system() instead of exec() because then I open a can of worms regarding the quoting of arguements to the programs being exec()'d (the arguements themselves may contain quotes and/or spaces, and going through the shell on the two different OS's is a whole lot of extra code I can avoid if exec() would just act right :-)

Aaron


In reply to windows vs unix: different behaviour with exec() by abecher

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.