"abc"
string was stored to shared memory.
The program has finished (quit) by return 0;
but the string is still stored in memory.
How long will it remain there?
Will it remain there until system reboot?
Can it be relied on that it will remain there?
Relevant code:
int main() {
int mem_id;
key_t key;
char * string;
key = 01;
int str_len;
str_len = strlen("abc") + 1;
mem_id = shmget(key, str_len, IPC_CREAT | 0666);
string = shmat(mem_id, NULL, 0);
strcpy ( string, "abc" );
return 0;
}
shmctl
function. – Marian