in reply to exec on Windows "halfway forks"

Have you tried checking the return code from exec?

Because on my system exec never returns, so quite how you are reaching the while loop I do not understand.

Try running this:

perl -e"warn $$; exec 'notepad'; warn 'here'"

You'll see the pid printed & notepad start, but never see 'here'.


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.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: exec on Windows "halfway forks"
by JavaFan (Canon) on Jun 14, 2010 at 18:27 UTC
    Because on my system exec never returns, so quite how you are reaching the while loop I do not understand.
    The exec calls the same program. The while loop is reached in the execed program.

      So it does. What a convoluted mechanism to achieve ?

Re^2: exec on Windows "halfway forks"
by rovf (Priest) on Jun 15, 2010 at 11:28 UTC
    As you observe correctly, exec does not return. The while loop is only reached if the if condition inside the INIT is false, i.e. (typically) on the recursive call, when the program is called using an absolute path name.

    -- 
    Ronald Fischer <ynnor@mm.st>

      You seem to be leaping through extraordinary hoops in order to achieve what happens naturally on my system:

      C:\test>p1 [0] Perl> print $0;; C:\Perl64\bin\p1.pl [0] Perl> print $^X;; C:\perl64\bin\perl.exe ^C C:\test>cd \Perl64\bin C:\Perl64\bin>.\p1.pl [0] Perl> print $0;; C:\Perl64\bin\p1.pl [0] Perl> print $^X;; C:\perl64\bin\perl.exe

      And under both the above circumstances, ProcessExplorer shows the fully qualified path of both the perl executable and the script being run.

      Do you know of circumstances where that is not the case?