Skip to content

Instantly share code, notes, and snippets.

@0x75
Created June 27, 2013 13:49
Show Gist options
  • Save 0x75/5876556 to your computer and use it in GitHub Desktop.
Save 0x75/5876556 to your computer and use it in GitHub Desktop.
mach msg server
void mach_msg_server(mach_port_t exception_port) {
mach_msg_return_t r;
r = mach_msg(&msg.head, MACH_RCV_MSG|MACH_RCV_LARGE|MACH_RCV_TIMEOUT, 0, sizeof(msg), exception_port, 0, MACH_PORT_NULL);
assert(r != MACH_RCV_TIMED_OUT);
assert (r == MACH_MSG_SUCCESS);
mach_exc_server(&msg.head, &reply.head);
r = mach_msg(&reply.head, MACH_SEND_MSG|MACH_SEND_TIMEOUT, reply.head.msgh_size, 0, MACH_PORT_NULL, 0 ,MACH_PORT_NULL);
assert(r != MACH_SEND_TIMED_OUT);
assert(r == MACH_MSG_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment