I've tried to make use of the task-for-pid-allow entitlement to get the task port of a process on iOS but I cannot get it working:
I could get the task port but every operation on it failed,
task_for_pid(mach_task_self(), child_pid, &target_task)
task_info(target_task, TASK_DYLD_INFO, (void *) &tdi, &cnt);
I believed it was because my app is missing the TF_PLATFLORM=1 flag and someone was suggesting to use posix_spawn on an actual platform binary and then use its entitlements but even in this case I get an error when I try to use the child task both with or without the flag SUSPENDED:
pid_t child_pid;
char *argv[] = { "/bin/ps", NULL };
int status;
posix_spawnattr_t attr;
status = posix_spawnattr_init(&attr);
if (status != 0) {
perror("can't init spawnattr");
}
status = posix_spawnattr_setflags(&attr, POSIX_SPAWN_START_SUSPENDED);
if (status != 0) {
perror("can't set flags");
}
int s = posix_spawn(&child_pid, "/bin/ps", 0, &attr, argv, NULL);
task_for_pid(mach_task_self(), child_pid, &target_task)
task_info(target_task, TASK_DYLD_INFO, (void *) &tdi, &cnt);