And, does someone know a better way to "restart myself"?I would use $^X instead of $Config{perlpath}, since the perl executable might not be where it was configured for it to be. No need to "use Config" to get $^X.
However the behaviour I am experiencing, does not match this either. Instead, I get a CMD.EXE shell plus my Perl program in parallel! Any explanation for this?If you want really interesting behavior, try this in the dummy code:
Then you'll see that when that thread comes out of sleep, it grabs stdin. Otherwise, the CMD shell has it.while(1) { sleep(5); my $x=scalar<>;print "running $$:$x\n"; }
My guess is that the parent thread, started with the relative path, starts a new thread with the EXEC and then exits, giving control back to the shell. The child thread (started with an absolute path) inherited stdin & stdout, so its input & output are interleaved with the command window.
My suggestion is to not respawn. Just overwrite $0!
That is, "lie" to make it look like your script was started with an absolute path.$0=rel2abs($0) unless file_name_is_absolute $0;
In reply to Re: exec on Windows "halfway forks"
by Yary
in thread exec on Windows "halfway forks"
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |