Forwarded from threads-shared forum:
> <p>I have a threaded app where, each thread invokes other processes
> (I know - already dead in the water but bear with me).</p>
> 
> <p>For the moment I'm using qx, tho' I could also use any one of the
> open derivatives with pipes or open2/3 semantics or whatever.</p>
> 
> <p>Anyhow, in the thread, I want to set an env var specific to that
> thread that will condition how the subprocess invoked from it
> runs.</p>
> 
> <p>Now, I can - in the thread - set, e.g.</p>
> 
> <code>
> $ENV{RUN_DIR} = "/run_dirs/$tid"; 
> </code>
> 
> <p>...and, if I look at that - per thread it's indeed changing *some*
> copy of %ENV - I can even lock it and see the changes between
> threads. But, when I call qx in the thread, the %ENV (or at least,
> the inherited environment) is that of the *parent* thread before any
> threads were started.</p>
> 
> <p>Can anyone suggest a way to do this? I saw the article about cwd
> which confirmed what I was seeking to do that I was doing something
> like that - but no dice.</p>
> 
> <p>My only other current solution is to do something like this:</p>
> 
> <code>
> my $env = qq(export A=$A C=$C E=$E); # etc
> my $cmd = qq(some external command);
> 
> my $result = qx($env ; $cmd);
> </code>
> 
> <p>which works.</p>
> 
> <p>This tripped me up moving from a non-threaded app to a threaded
> version. The non-threaded one of course inherits the environment
> changes in qx just fine.</p>
> <p>Kind regards</p>
> 
> <p>Derek Jones.</p>
> 
> <p>" What a tangled web we weave when of threads we do
> conceive...."</p>
> 
> 
> To write a respons, access
> http://www.cpanforum.com/response_form/4002
> 
> To see the full thread, access
> http://www.cpanforum.com/threads/4002

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to