Skip to content

Instantly share code, notes, and snippets.

@jvns
Created January 28, 2018 05:49
Show Gist options
  • Save jvns/16c1ea69352a81658d6d8e9c5a289f2a to your computer and use it in GitHub Desktop.
Save jvns/16c1ea69352a81658d6d8e9c5a289f2a to your computer and use it in GitHub Desktop.
#include <mach/mach_init.h>
#include <mach/port.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
int main() {
for (;;) {
pid_t pid = fork();
if (pid == 0) execv("/usr/bin/true", NULL);
mach_port_name_t task = MACH_PORT_NULL;
task_for_pid(mach_task_self(), pid, &task);
printf("Ran task_for_pid\n");
int wait_status;
wait(&wait_status);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment