I was coding some C when I started asking myself about
free() inside a shared library and
SIGKILL, and so on. Then, after some reading and re-thinking, I came up to this simple question.
CONTEXT : When the loader reads an ELF file that points to some libA.so shared object, and it loads the library, will it map the entire segments onto the program's memory address space? will it assign it as shared memory?
As far as I know, the kernel will not take shared memory of dead processes, so:
- What happens if a shared object was loaded, and it allocates memory, and then the main program receives
SIGKILL? Will the allocated memory be considered shared memory and be a leak?
- What happens if I have two programs loading the same shared library, and one of them dies without freeing?
Both ended up as: Is the shared library object loaded as shared memory for the program?
My question is quite generic. I would love to compare different kernels / loaders.