Im just trying to share an integer between two processes, but the memory segment is initialized in program 1 and is used in program 4. Here is the initialization in program 1:
shmid = shmget(key, sizeof(int*), 0666 | IPC_CREAT);
int *data = (int *)shmat(shmid, (void*)0,0);
Here I get a warning of "cast to pointer from integer of different size". Argh.
Simple, I'm assuming, but I'm a big time noob with IPC. And many other things in c....
Then I pass it to another program:
snprintf(shmarg, sizeof(shmarg), "%n", data);
pid_t pid3 = run_cmd4("/home/tropix/hw11-4", shmarg, semarg, pipe_from_p2_2, pipe_to_p5_2);
Not sure how to access it on the other side though. How can I get the int back in Program 4?