Skip to content

Instantly share code, notes, and snippets.

@jvns

jvns/freeze-mac.c

Created Jan 28, 2018
Embed
What would you like to do?
#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