Hi I would like to send bunch of data from process A to process B
through shared memory. Also I would like it so that when Process A finishes writting to the share memory, only then process B should read it.
How can I make this work. I have tried putting together a simple program where process A writes to share memory. and terminates. Then I exe process B to read from that share memory but it doesn’t work.
oh, that was a mistake an my part. I did change the process B code to use shm_open but I still fail on mmap.
how can I make this code work? I think something is with size parameter in mmap in both process, and reading the share memory in process B. Thanks
I can see that I have created a 1024 byte of shared memory and used mmap of size int which is 4byte. So should have index it upto
256 instead of 1024. But even with turning on the warning level to 9 I didn’t see any compile problem with either code. and when I run the process B, it still fails at mmap with error number 48.
Ok I’ll help you with one cause it is kind of tricky
ff(fd=shm_open("/bolts",O_RDONLY,0) == -1)
This doesn’t work because == has precedence over = so fd will be equal to the result of shm_open() == -1 which is false so fd will be equal to 0. You need
ff( (fd=shm_open("/bolts",O_RDONLY,0)) == -1)
As for the other problem it’s so obvious that I will not do it for you…