Communicating a memory entry between two unrelated processes
site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com -tim ---- kern_return_t krc; vm_address_t addr; vm_size_t byteCount = 0x20000; krc = vm_allocate(mach_task_self(), &addr, byteCount, TRUE); if (krc != KERN_SUCCESS) { mach_error("vm_allocate", krc); 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... I was testing setting up a shared memory entry between two tasks. The tasks process started out with the following code. The interesting bit here was that for expediency, I allocated the memory object and registered it with the bootstrap server. I was assuming that if all users tasks with rights to the memory entry died, that the bootstrap server wouldn't hold onto the port (just like it does for my mig server ports). But, if I run this code twice, the second registration fails with BOOTSTRAP_SERVICE_ACTIVE. Clearly, I assumed wrong. Is there any way to get the port transfered between two processes (both with the same uid in this case) without having a mig server in the vending process to return the memory entry port to callers? mem_entry_name_port_t memoryEntry = PORT_NULL; krc = mach_make_memory_entry(mach_task_self(), &byteCount, addr, VM_PROT_READ|VM_PROT_WRITE, &memoryEntry, PORT_NULL/*parent*/); if (krc != KERN_SUCCESS) { mach_error("mach_make_memory_entry", krc); return 1; } mach_port_t bootstrapPort; krc = task_get_bootstrap_port(mach_task_self(), &bootstrapPort); if (krc != KERN_SUCCESS) { fprintf(stderr, "task_get_bootstrap_port, krc = %d, %s\n", krc, mach_error_string(krc)); return 1; } krc = bootstrap_register(bootstrap_port, "Memory Test", memoryEntry); if (krc != KERN_SUCCESS) { fprintf(stderr, "bootstrap_register, krc = %d, %s\n", krc, mach_error_string(krc)); return 1; } This email sent to site_archiver@lists.apple.com
participants (1)
-
Timothy J. Wood