PROCCTL(2)

NAME
procctl - control processes

LIBRARY
libc

SYNOPSIS
#include <sys/procctl.h>
int
procctl(idtype_t idtype, id_t id, int cmd, void *arg);

DESCRIPTION
The procctl() system call provides for control over processes. The idtype and id arguments specify the set of processes to control. If multiple processes match the identifier, procctl will make a “best effort” to control as many of the selected processes as possible. An error is only returned if no selected processes successfully complete the request. The following identifier types are supported:

P_PID
    Control the process with the process ID id.

P_PGID
    Control processes belonging to the process group with the ID id.

The control request to perform is specified by the cmd argument. The following commands are supported:

PROC_SPROTECT
    Set process protection state. This is used to mark a process as protected from being killed if the system exhausts available memory and swap. The arg parameter must point to an integer containing an operation and zero or more optional flags. The following operations are supported:

    PPROT_SET
        Mark the selected processes as protected.

    PPROT_CLEAR
        Clear the protected state of selected processes.

    The following optional flags are supported:

    PPROT_DESCEND
        Apply the requested operation to all child processes of each selected process in addition to each selected process.

    PPROT_INHERIT
        When used with PPROT_SET, mark all future child processes of each selected process as protected. Future child processes will also mark all of their future child processes.

RETURN VALUES
If an error occurs, a value of -1 is returned and errno is set to indicate the error.

ERRORS
The procctl() system call will fail if:

[EFAULT]
    The arg points outside the process's allocated address space.

[EINVAL]
    The cmd argument specifies an unsupported command.

    The idtype argument specifies an unsupported identifier type.

[EPERM]
    The calling process does not have permission to perform the requested operation on any of the selected processes.

[ESRCH]
    No processes matched the requested idtype and id.

[EINVAL]
    An invalid operation or flag was passed in arg for a PROC_SPROTECT command.

SEE ALSO
ptrace(2)

HISTORY
The procctl() function appeared in FreeBSD 10.