Hi,
I have serious problems sharing memory in my embedded Linux application. I have looked up the Linux documentation, found some code snippets and in addition used it for years in Windows but it will not initialze here. Here is my condensed code:
int init_mmap(void) { unsigned char result; int fd;
fd=fopen("shared_mem.dat", "a+"); shared_mem_prt=mmap(0, 1024, PROT_READ+PROT_WRITE, MAP_SHARED, fd,
0);result=0; return result; }
The file already exists, has the correct size and does open. The problem is that the mmap always return -1 which means a failure and errno return subsequently 9. I have tried various other open modes and shar modes but each time with the same result.
Can sombody please tell me what I am doing wrong?
I need this to communicate between two different applications. Is shared memory the best way to do it or are there other ways in Linux? (Sorry but my background is windows)
Thanks,
Jens.