Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: passing env{} variable to child fails on linux,works on windows

by sdetweil (Sexton)
on Jan 13, 2013 at 13:39 UTC ( #1013100=note: print w/ replies, xml ) Need Help??


in reply to Re^3: passing env{} variable to child fails on linux,works on windows
in thread passing env{} variable to child fails on linux,works on windows

thank you.

using your example I tested on my platform, and it worked.

but my app didn't..

the difference was that I called $ENV{} from the thread code (&routine below), vs the main app code..

threads->create(&routine);


moving the $ENV{} to the main code allows it to work.

$ENV{'SKIP_SYSTEM'}='1'; threads->create(&routine);


Comment on Re^4: passing env{} variable to child fails on linux,works on windows
Select or Download Code
Re^5: passing env{} variable to child fails on linux,works on windows
by andal (Friar) on Jan 14, 2013 at 09:19 UTC

    Here's the quote from perdloc threads

    Currently, on all platforms except MSWin32, all system calls (e.g., us +ing system() or back-ticks) made from threads use the environment var +iable settings from the main thread. In other words, changes made to +%ENV in a thread will not be visible in system calls made by that thr +ead. To work around this, set environment variables as part of the system c +all. For example: my $msg = 'hello'; system("FOO=$msg; echo \$FOO"); # Outputs 'hello' to STDOUT On MSWin32, each thread maintains its own set of environment variables +.
Re^5: passing env{} variable to child fails on linux,works on windows
by thargas (Chaplain) on Jan 14, 2013 at 13:49 UTC
    One problem with your question is that you're using the word "child". For most unix folks, child implies that you're using fork, which you're not. Fork and threads work differently. The problem could have been avoided by providing a complete script.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-07-28 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (199 votes), past polls