Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: LD_LIBRARY_PATH setting

by pdupre (Acolyte)
on Aug 05, 2016 at 19:08 UTC ( [id://1169214]=note: print w/replies, xml ) Need Help??


in reply to Re^3: LD_LIBRARY_PATH setting
in thread LD_LIBRARY_PATH setting

#!/usr/bin/perl BEGIN { $ENV{LD_LIBRARY_PATH} = "/usr/local/gsl-1/lib" ; exec $0, '--restarted', @ARGV ; } ; require Math::GSL ; use strict; use warnings; print $ENV{LD_LIBRARY_PATH}, "\n";
Can't load '/usr/lib/perl5/vendor_perl/auto/Math/GSL/Errno/Errno.so' +for module Math::GSL::Errno: libgsl.so.0: cannot open shared object f +ile: No such file or directory at /usr/lib/perl5/DynaLoader.pm line 1 +93. at /usr/lib/perl5/vendor_perl/Math/GSL/Errno.pm line 11. Compilation failed in require at /usr/lib/perl5/vendor_perl/Math/GSL/T +est.pm line 7. BEGIN failed--compilation aborted at /usr/lib/perl5/vendor_perl/Math/G +SL/Test.pm line 7. Compilation failed in require at /usr/lib/perl5/vendor_perl/Math/GSL.p +m line 10. BEGIN failed--compilation aborted at /usr/lib/perl5/vendor_perl/Math/G +SL.pm line 10. Compilation failed in require at ./test.pl line 10.
Patrick Dupre Universite du Littoral, FR Dunkirk

Replies are listed 'Best First'.
Re^5: LD_LIBRARY_PATH setting
by Corion (Patriarch) on Aug 05, 2016 at 19:14 UTC

    This is higly weird because I would expect that code to go into an endless self-exec loop instead of producing that error message. You never check for the self-restart flag.

    Maybe consider adding more debug output, for example two print statements around the exec statement:

    ... print "Rerunning $0 --restarted @ARGV\n"; exec $0, '--restarted', @ARGV or print STDERR "couldn't exec foo: $!"; ...

    Also, if you put your code in between <code>...</code> tags, it renders and downloads much better.

      Rerunning ./test.pl --restarted --restarted --restarted --restarted --restarted --restarted --restarted --restarted --restarted --restarted --restarted --restarted -

      Patrick Dupre Universite du Littoral, FR Dunkirk

        In the code I originally posted, I included a guard flag that told the program whether it had been restarted.

        The code that you have not shown does not seem to guard against an endless restart loop, as evidenced by the small and incomplete part of its output that you've shown.

        Maybe now is a good time to revisit the approach I had outlined in my first program?

        if( ! $ENV{PDUPRE_RESTART}) { $ENV{PDUPRE_RESTART} = 1; print "Restarting as '$0, @ARGV'\n"; ... exec $0, @ARGV or print "Exec error when restarting $0 @ARGV: $!"; exit 1; };

        Alternatively, if you want to keep the --restarted command, maybe you can check @ARGV whether it contains --restarted?

        if( ! grep { /^--restarted$/ @ARGV) { print "Restarting as '$0 --restarted @ARGV'\n"; exec $0, '--restarted', @ARGV or print "Exec error when restarting $0 @ARGV: $!"; exit 1; };

        Again, you can help us help you diagnosing things better by posting a twenty-line self-contained example that reproduces the behaviour you're seeing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1169214]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found