case PROC_POLICY_RUSAGE_DISK:
case PROC_POLICY_RUSAGE_NETWORK:
case PROC_POLICY_RUSAGE_POWER:
- return(ENOTSUP);
+ error = ENOTSUP;
+ goto out;
default:
- return(EINVAL);
+ error = EINVAL;
+ goto out;
case PROC_POLICY_RUSAGE_CPU:
break;
}
}
#endif
+ // on macOS tasks can only set and clear their own CPU limits
+ if ((action == PROC_POLICY_ACTION_APPLY || action == PROC_POLICY_ACTION_RESTORE)
+ && proc != current_proc()) {
+ return (EPERM);
+ }
+
switch (action) {
case PROC_POLICY_ACTION_GET:
error = proc_get_task_ruse_cpu(proc->task, &cpuattr.ppattr_cpu_attr,