develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123775] Args to 'system' not evaluated before forking, making $$ wrong

Thread Previous | Thread Next
From:
Chris Wagner via RT
Date:
February 17, 2015 09:51
Subject:
[perl #123775] Args to 'system' not evaluated before forking, making $$ wrong
Message ID:
rt-4.0.18-26690-1424107431-386.123775-15-0@perl.org
On Sat Feb 14 17:10:11 2015, LeonT wrote:
> I would still expect that to run into pseudothreads on Windows, but I
> haven't tested either version on Windows yet.
> 
> Leon

The problem on Windows is likely masked by the pseudo-fork.  It prints the "right pid".  I verified that two Perl processes get made with the right pids in TaskInfo.

C:\>perl -le "print qq/$^V\nparent pid $$/; system qw/perl -le/, q/print qq{passed pid $ARGV[0]\nchild pid $$}/, $$;"
v5.20.0
parent pid 12060
passed pid 12060
child pid 13764

This can be elucidated with the following fork example.
C:\>perl -le "print qq/start pid $$/; if ($p=fork) { print qq/parent p `$p` pid $$/; sleep 10; } else { print qq/child p `$p` pid $$/; sleep 10; } "
start pid 6928
parent p `-9540` pid 6928
child p `0` pid -9540

This pid is negative and there is only ever one Perl process in TaskInfo.  So I would say that any improper symbol evaluation is taking place in the 2nd thread.  This could still be a problem depending on what is behind a tie()'d variable.


I've come up with this command line that could serve as a universal test case for system() atleast.  Change the quotation marks for Unix of course.
perl -le "print qq/$^V\nparent pid $$/; system qw/perl -le/, q/print qq{passed pid $ARGV[0]\nchild pid $$}/, $$;"

Does GETMAGIC cause FETCH to be executed on tie()'d variables?


Thanks.


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123775

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About