Hi,
does anyone know how i can read out a shared memory segment by using the shm_id? I have two progs. the one creates the segment and writes a value into the shm, which is given as parameter. the second is supposed to read out the shm unfortunately it shows me the environment variable USER=***** for my user account. the following are fragments of the programm code. WOuld be great if someone could help me.
Programm one:
int main(int argc, int argv[]){
int i, id, arg;
char *shared_mem;
id = shmget(IPC_PRIVATE, SEGSIZE, IPC_CREAT | 0644);
shared_mem = shmat(id, 0, 0);
arg = argv[1];
*shared_mem = arg;
printf("Die id vom Shared Memory ist %i\n", id);
...
programm two:
int main(int argc, char *argv[]){
int i, id, id2, *shared_mem, *tmp;
char *arg;
arg = argv[1];
id = atoi(arg);
shared_mem = (int *)shmat(id, 0, 0);
printf("Der inhalt vom Shared Memory ist %s\n", *shared_mem);
...
cheers
Hauke