Your code is not putting your strings in shared memory. It's putting them on the heap, as malloc
always does, because you are doing:
buf = (char**) shmat(shm_handle, 0, 0);
...
/* now throw away the value of `buf` you got from shm */
buf = malloc(sizeof(char*) * BUFF_SIZE);
What you will have to do is:
Not use the heap to allocate things you want in shared memory
Instead, grab a large enough amount of shared memory for everything, then copy it in, entry by entry - i.e. lay it out in memory manually.