I used dlopen
to load a dynamic link library (.so) in my program, called dlsym
to get the address to a certain function foo
.
Then I used fork
and called foo
in the sub-process, and used exit(0)
to exit the sub-process. Till now, everything is alright.
And when I tried to fork
and call foo
again in the sub-process, I found that all data stored by static variables defined in foo
was lost. I am sure that I didn't call functions like dlclose
explicitly. So how can I prevent the data from disappearing?
Thanks a lot.