Is it possible to use global variable located in a shared library (.so) as a singleton if the library is used by more than one process?
As example the initial value is 0, process 1 increments the var then proc2 increments the val and prints it.
My experiments so far showed that the both process keep copies of the variable and if 1st increments it the second will still read 0. So the behavior is not like Windows DLLs...
I read in one article here that if the global variable is not static (in the lib) and it's declared as extern in the lib header the var is unique for all the process. But so far I haven't been able to accomplish this - var is still copy for each process.
Can someone please offer good explanation of this? And how to do it...