Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

eval and chroot strange behavior

by recsky (Sexton)
on Apr 02, 2008 at 05:27 UTC ( #677892=perlquestion: print w/ replies, xml ) Need Help??
recsky has asked for the wisdom of the Perl Monks concerning the following question:

Hi , I was writing a script and the -X file tests start to fail after some point. After search, they start to fail after this:
my @list = eval {chroot $config{root}; chdir "/"; qx / ldd $my_bin / } +;
In true the problem is the chroot, but I suppose that inside eval it not propagate in the rest program. Some tip or sugestion? Running at v5.8.8.

Comment on eval and chroot strange behavior
Download Code
Re: eval and chroot strange behavior
by pc88mxer (Vicar) on Apr 02, 2008 at 06:13 UTC
    In true the problem is the chroot, but I suppose that inside eval it not propagate in the rest program.
    This is not the case. eval doesn't preserve your process's root directory. So if you change it with chroot, it remains changed until you change it again.

    One way you might be able to accomplish what you want to do is to execute your code in a child process and communicate the result back to the parent.

      As above, and this is how you fix it:

      my @list = qx{chroot $config{root} ldd $my_bin/};

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://677892]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (17)
As of 2014-07-31 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls