Originally Posted by
Salem
What did you try?
Did you try
int *membuffer;
Here's the code from the host process:
Code:
#define CTRL_PATH = "/tmp/control"
shm_unlink(CTRL_PATH); //in case of previous crash
int fd_ctl = shm_open(CTRL_PATH, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
ftruncate(fd_ctl, sizeof(int));
int *control_code_ptr = (int*)mmap(0, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, fd_ctl, 0);
close(fd_ctl);
int ctrl_code;
control_code_ptr = &ctrl_code;
ctrl_code = 123;
fprintf(stderr, "Control code set to %d\n",*control_code_ptr); //works fine
And the code from the receiving process:
Code:
int fd_ctl = shm_open(CTRL_PATH, O_RDWR, S_IRUSR | S_IWUSR);
int *control_code_ptr = (int*)mmap(0, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, fd_ctl, 0);
close(fd_ctl);
fprintf(stderr, "Control code received was %d\n",*control_code_ptr); //always returns 0
The control code I get is always 0. However, if I set the code from within the child process, that works. That doesn't help me though with communicating between processes -- each process needs to be able to read and write values read/written from other processes.