#include <libproc.h>
libproc.h
for audit_token_t
macroPROC_LISTPIDSPATH_PATH_IS_VOLUME
@define PROC_LISTPIDSPATH_PATH_IS_VOLUME
@discussion This flag indicates that all processes that hold open
file references on the volume associated with the specified
path should be returned.
#define PROC_LISTPIDSPATH_PATH_IS_VOLUME 1
macroPROC_LISTPIDSPATH_EXCLUDE_EVTONLY
@define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY
@discussion This flag indicates that file references that were opened
with the O_EVTONLY flag should be excluded from the matching
criteria.
#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY 2
functionproc_listpidspath
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_listpidspath(
uint32_t type,
uint32_t typeinfo,
const char *path,
uint32_t pathflags,
void *buffer,
int buffersize
)@function proc_listpidspath
@discussion A function which will search through the current
processes looking for open file references which match
a specified path or volume.
@param type types of processes to be searched (see proc_listpids)
@param typeinfo adjunct information for type
@param path file or volume path
@param pathflags flags to control which files should be considered
during the process search.
@param buffer a C array of int-sized values to be filled with
process identifiers that hold an open file reference
matching the specified path or volume. Pass NULL to
obtain the minimum buffer size needed to hold the
currently active processes.
@param buffersize the size (in bytes) of the provided buffer.
@result the number of bytes of data returned in the provided buffer;
-1 if an error was encountered;
functionproc_listpids
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize)functionproc_listallpids
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1)
int proc_listallpids(void * buffer, int buffersize)functionproc_listpgrppids
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1) int proc_listpgrppids(pid_t pgrpid, void * buffer, int buffersize)
functionproc_listchildpids
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1) int proc_listchildpids(pid_t ppid, void * buffer, int buffersize)
functionproc_pidinfo
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize)functionproc_pidfdinfo
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_pidfdinfo(int pid, int fd, int flavor, void * buffer, int buffersize)functionproc_pidfileportinfo
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3)
int proc_pidfileportinfo(
int pid,
uint32_t fileport,
int flavor,
void *buffer,
int buffersize
)functionproc_name
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_name(int pid, void * buffer, uint32_t buffersize)functionproc_regionfilename
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize)functionproc_kmsgbuf
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_kmsgbuf(void * buffer, uint32_t buffersize)functionproc_pidpath
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int proc_pidpath(int pid, void * buffer, uint32_t buffersize)functionproc_pidpath_audittoken
API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) int proc_pidpath_audittoken(audit_token_t *audittoken, void * buffer, uint32_t buffersize)
functionproc_libversion
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) int proc_libversion(int *major, int * minor)
functionproc_pid_rusage
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) int proc_pid_rusage(int pid, int flavor, rusage_info_t *buffer)
Return resource usage information for the given pid, which can be a live process or a zombie.
Returns 0 on success; or -1 on failure, with errno set to indicate the specific error.
macroPROC_SETPC_NONE
A process can use the following api to set its own process control
state on resoure starvation. The argument can have one of the PROC_SETPC_XX values
#define PROC_SETPC_NONE 0
macroPROC_SETPC_THROTTLEMEM
#define PROC_SETPC_THROTTLEMEM 1
macroPROC_SETPC_SUSPEND
#define PROC_SETPC_SUSPEND 2
macroPROC_SETPC_TERMINATE
#define PROC_SETPC_TERMINATE 3
functionproc_setpcontrol
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
int proc_setpcontrol(const int control)functionproc_setpcontrol
int proc_setpcontrol(const int control)
functionproc_track_dirty
int proc_track_dirty(pid_t pid, uint32_t flags)
functionproc_set_dirty
int proc_set_dirty(pid_t pid, bool dirty)
functionproc_get_dirty
int proc_get_dirty(pid_t pid, uint32_t *flags)
functionproc_clear_dirty
int proc_clear_dirty(pid_t pid, uint32_t flags)
functionproc_terminate
int proc_terminate(pid_t pid, int *sig)
functionproc_terminate_all_rsr
int proc_terminate_all_rsr(int sig)
functionproc_signal_with_audittoken
int proc_signal_with_audittoken(audit_token_t *audittoken, int sig)
functionproc_terminate_with_audittoken
int proc_terminate_with_audittoken(audit_token_t *audittoken, int *sig)
functionproc_signal_delegate
int proc_signal_delegate(audit_token_t instigator, audit_token_t target, int sig)
functionproc_terminate_delegate
int proc_terminate_delegate(audit_token_t instigator, audit_token_t target, int *sig)
functionproc_set_no_smt
__API_AVAILABLE(macos(11.0))
int proc_set_no_smt(void)NO_SMT means that on an SMT CPU, this thread must be scheduled alone,
with the paired CPU idle.
Set NO_SMT on the current proc (all existing and future threads)
This attribute is inherited on fork and exec
functionproc_setthread_no_smt
__API_AVAILABLE(macos(11.0))
int proc_setthread_no_smt(void)Set NO_SMT on the current thread
functionproc_set_csm
__API_AVAILABLE(macos(11.0))
int proc_set_csm(uint32_t flags)CPU Security Mitigation APIs
Set CPU security mitigation on the current proc (all existing and future threads)
This attribute is inherited on fork and exec
functionproc_setthread_csm
__API_AVAILABLE(macos(11.0))
int proc_setthread_csm(uint32_t flags)Set CPU security mitigation on the current thread
macroPROC_CSM_ALL
flags for CPU Security Mitigation APIs
PROC_CSM_ALL should be used in most cases,
the individual flags are provided only for performance evaluation etc
#define PROC_CSM_ALL 0x0001
Set all available mitigations
functionproc_udata_info
int proc_udata_info(int pid, int flavor, void *buffer, int buffersize)