site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Organization: Heeltoe Consulting Can anyone explain why this doesn't work on darwin? I want to create shared memory space which two processes can access. The shm_open works but the mmap fails. I can't figure out why (but have not looked at the sources yet) I've tried all manner of mprot and mflags. I did find the mmap would work if I used "open" instead of "shm_open" *and* the file size was >= the mmap size. The code below always fails at the mmap. I thought shm_open + mmap would work on os 10.4... int shared_fb_init(void) { int ret, shm_fd, mprot, mflags, ps; size_t size; ret = shm_unlink(shm_filename); printf("shm_unlink ret %d\n", ret); shm_fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0666); if (shm_fd < 0) { perror(shm_filename); return -1; } size = MAX_BITMAP_OFFSET*4; mprot = PROT_READ|PROT_WRITE; mflags = MAP_FILE|MAP_SHARED; ps = getpagesize(); printf("pagesize %d\n", ps); size = ((size+ps-1)/ps) * ps; printf("shm_fd %d, size %d\n", shm_fd, size); shm_fb = mmap(NULL, size, mprot, mflags, shm_fd, (off_t)0); if (shm_fb == (void *)-1) { fprintf(stderr, "mmap of %s failed\n", shm_filename); perror(shm_filename); return -1; } ... _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Brad Parker