-#if CONFIG_EMBEDDED
-kern_return_t
-pid_hibernate(struct proc *p __unused, struct pid_hibernate_args *args, int *ret)
-{
- int error = 0;
- proc_t targetproc = PROC_NULL;
- int pid = args->pid;
-
-#ifndef CONFIG_FREEZE
- #pragma unused(pid)
-#else
-
-#if CONFIG_MACF
- error = mac_proc_check_suspend_resume(p, MAC_PROC_CHECK_HIBERNATE);
- if (error) {
- error = EPERM;
- goto out;
- }
-#endif
-
- /*
- * The only accepted pid value here is currently -1, since we just kick off the freeze thread
- * here - individual ids aren't required. However, it's intended that that this call is to change
- * in the future to initiate freeze of individual processes. In anticipation, we'll obtain the
- * process handle for potentially valid values and call task_for_pid_posix_check(); this way, everything
- * is validated correctly and set for further refactoring. See <rdar://problem/7839708> for more details.
- */
- if (pid >= 0) {
- targetproc = proc_find(pid);
- if (targetproc == PROC_NULL) {
- error = ESRCH;
- goto out;
- }
-
- if (!task_for_pid_posix_check(targetproc)) {
- error = EPERM;
- goto out;
- }
- }
-
- if (pid == -1) {
- memorystatus_on_inactivity(pid);
- } else {
- error = EPERM;
- }
-
-out:
-
-#endif /* CONFIG_FREEZE */
-
- if (targetproc != PROC_NULL)
- proc_rele(targetproc);
- *ret = error;
- return error;
-}
-
-int
-pid_shutdown_sockets(struct proc *p __unused, struct pid_shutdown_sockets_args *args, int *ret)
-{
- int error = 0;
- proc_t targetproc = PROC_NULL;
- struct filedesc *fdp;
- struct fileproc *fp;
- int pid = args->pid;
- int level = args->level;
- int i;
-
- if (level != SHUTDOWN_SOCKET_LEVEL_DISCONNECT_SVC &&
- level != SHUTDOWN_SOCKET_LEVEL_DISCONNECT_ALL)
- {
- error = EINVAL;
- goto out;
- }
-
-#if CONFIG_MACF
- error = mac_proc_check_suspend_resume(p, MAC_PROC_CHECK_SHUTDOWN_SOCKETS);
- if (error) {
- error = EPERM;
- goto out;
- }
-#endif
-
- targetproc = proc_find(pid);
- if (targetproc == PROC_NULL) {
- error = ESRCH;
- goto out;
- }
-
- if (!task_for_pid_posix_check(targetproc)) {
- error = EPERM;
- goto out;
- }
-
- proc_fdlock(targetproc);
- fdp = targetproc->p_fd;
-
- for (i = 0; i < fdp->fd_nfiles; i++) {
- struct socket *sockp;
-
- fp = fdp->fd_ofiles[i];
- if (fp == NULL || (fdp->fd_ofileflags[i] & UF_RESERVED) != 0 ||
- fp->f_fglob->fg_type != DTYPE_SOCKET)
- {
- continue;
- }
-
- sockp = (struct socket *)fp->f_fglob->fg_data;
-
- /* Call networking stack with socket and level */
- (void) socket_defunct(targetproc, sockp, level);
- }
-
- proc_fdunlock(targetproc);
-
-out:
- if (targetproc != PROC_NULL)
- proc_rele(targetproc);
- *ret = error;
- return error;
-}
-#endif /* CONFIG_EMBEDDED */