Simply storing an integer in a shared memory segment: C?

Pretty sure you're missing the header that defines shmat() and thus the compiler is guessing that shmat returns an int (not a pointer).

Here I get a warning of "cast to pointer from integer of different size". Argh. Try using NULL instead of (void*)0.

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? The pointer itself isn't useful unless the shared memory area happens to be loaded at the exact same virtual memory address in the other program: you probably don't even want to try to arrange that - instead, let the other program (hw11-4) load the shared memory segment and let the OS choose the virtual memory address, then simply look at that address for the int.So, hw11-4 needs to be passed the same shared memory key (e.g. As a command line argument) and itself use shmget to open and get the key for, then shmat to map, the shared memory segment into memory....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions