kget_proc_info Kernel Service

Purpose

Allows a kernel extension to get information about a process or process group.

Syntax

#include <procinfo.h>

kerrno_t kget_proc_info ( cmd,id,data,size)
int cmd;
pid_t id;
void * data;
size_t * size;  

Parameters

Item Description
cmd Command indicating data to be returned.
id Process group ID (PID) for which the information is retrieved.
data Data region that contains the data returned
size Size of the data region

Description

The kget_proc_info kernel service retrieves information about a process or process group for a kernel extension. The following cmd values are supported, with the specified parameters and return codes:

Parameter Return Codes
VALIDATE_PID

This command determines if a PID or process group ID is valid. The data and size parameters are unused. This command will return 0 if the PID is valid, and ESRCH_INVALID_PID if it is not valid.

GET_PROCENTRY64

This command fills in a procentry64 structure for the given PID. The data should point to a struct procentry64 and size should be the size of a struct procentry64. This command will return 0 on success, EINVAL_NULL_SIZE for a NULL size parameter, EINVAL_NULL_DATA for a NULL data parameter, ESRCH_INVALID_PID if the PID is invalid, ERANGE_INSUFFICIENT_SIZE if size is insufficient to contain the struct procentry64, and EPERM_INSUFFICIENT_PRIVS if the current process is not allowed to obtain information about the target process.

GET_PGRP and GET_PGRP_BY_MEMBER

These commands fill in an array of PIDs in a process group. The process group is specified either by a process group PID (GET_PGRP) or the PID of a member of the process group (GET_PGRP_BY_MEMBER). If the data parameter is NULL, this will update the target size parameter with the size needed to hold all the PIDs. On successful return, the data parameter is filled with an array of PIDs and the size parameter is filled in with the actual size used. A value of 0 is returned for success. This command will return EINVAL_NULL_SIZE for a NULL size parameter, ESRCH_INVALID_PID if the PID is invalid, and ERANGE_INSUFFICIENT_SIZE if a data parameter is specified and size is insufficient to contain the array of PIDs. If the size is insufficient, the size parameter is updated with the correct needed size.

Note: While the data returned is consistent during the call, on return, the process or process group may change. Specifically, the size needed to hold the array of PIDs may be insufficient on a successive call.

Execution Environment

kget_proc_info must be called from the process environment only.

Return Values

Upon successful completion, 0 is returned. If the call is unsuccessful, an error number is returned as detailed in the corresponding command. Additionally, EINVAL_INVALID_COMMAND is returned for an invalid command.