I would like to lobby for evaluating all of the arguments that are not literal strings before the fork. True, $PID is the scenario at hand but there could be any number of cases down the road. The other obvious example is anything tie()'d. Spooky action at a distance is bad and I think the expected behavior of anything passed to system(), etc, is to be the value of the expression at that line of the program. I can think of one secenario where a tie variable returns memory information about the current process. Definately do not want that in the forked copy. Forgive me if I didn't see that in the proposed patch. For the test case, I have a better suggestion. It will work on any system. <code> + my $rv = system $Perl, '-e', 'exit ($ARGV[0] eq $$)', $$; + is($rv, 0, 'Pid is as expected in system'); + + skip 'Can\'t load POSIX' if not eval { require POSIX }; + if (my $child = open my $fh, '-|') { #parent + my $pid = <$fh>; + is($pid, $child, 'Pid is as expected in openpipe'); + } + else { #child + system $Perl, '-e', 'print $ARGV[0]', $$; + POSIX::_exit(0); + } </code> --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=123775Thread Previous | Thread Next