http://codepad.org/rHIKj7Cd (not the whole code)
What I'm trying to accomplish, is the parent to write something in the shared memory, then the child to react accordingly, and write something back, every five seconds. I thought about using SIGUSR1-2, and maybe switching on signum in the handler, but I don't know how to code that in, because setitimer throws SIGALRM. I obviously don't want to fork in the handler, cause i only need one child and one parent, so how do i define the different behaviour? I hope my goals are clear:
Every 5 seconds:
- SIGALRM is thrown by the timer
- Parent writes its calculations into shared memory (semaphores are being used)
- Child reads from shared memory, writes back it's calculations
I also know signal() is not adviced to use, this is not the point.