For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > January 2005 > Env. difference for dll and main program.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Env. difference for dll and main program.
Amit Verma

2005-01-17, 3:58 am

Hi,

I am having the following problem in Red Hat Linux 10 and am trying to
understand the issue here:

I have a shared library(.so) and there is a init function in it which
does a putenv to set NLSPATH var. This function is called in the
constructor of class A and the class A has a global static var in that
..so and hence this function is called while the dll is loading before
the main is called.(In gdb, the breakpoint in this function stops
before the main itself). If I go a getenv in the same function, the
var is well set.

However, as I enter main and try to retrieve the value of this var,
the env. var I had set is missing. Infact, any change in the env
during the loading of dll's is not reflected inside the main. Can
someone let me know what is happening. Does a .so open it's own shell
for loading and is not a part of the process space of the main
program??

Thanks for your time,
Amit Verma
Paul Pluzhnikov

2005-01-17, 3:59 pm

nehamit@gmail.com (Amit Verma) writes:

> I am having the following problem in Red Hat Linux 10


There exists no such thing: the last release of Red Hat Linux was 9.0.
What you probably have is Fedora Core {1,2,3}

> I have a shared library(.so) and there is a init function in it which


Post a minimal compilable and runnable example.

> Infact, any change in the env
> during the loading of dll's is not reflected inside the main. Can
> someone let me know what is happening.


It might be that your DSO is intializing itself (and performing
setenv()) before libc.so. When libc.so`_init fires, it resets the
environment back to its 'original' state, and your modifications
are lost. This could be happening if you linked your DSO or the
app incorrectly.

See if adding '-lc' to the end of the link line for the DSO cures
the problem.

> Does a .so open it's own shell


You are : neither the app, nor the DSO open any shells,
unless *you* ask them to.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com