PSTAT Interfaces
20
indicated process' address space. Additional information on VM regions mapped to files can be
obtained with the pstat_getfiledetails() call.
Return Value:
This call returns 1 on success or –1 on failure. It returns 0 when there are no regions to
copy.
Errors:
• EINVAL is set if the user's size declaration isn't valid.
• EINVAL is set if index is less than 0.
• ESRCH is set if elemcount > 0, and there is no active process with that PID.
• EFAULT is set if buf points to an invalid address.
Example:
#include <sys/pstat.h>
void main(void)
{
struct pst_vm_status pst;
int count1, count2, i = 0;
char name[100];
/* get info on all memory regions */
while (1) {
count1 = pstat_getprocvm(&pst, sizeof(pst), getpid(), i);
if (count1 == 0)
break;
if (count1 == -1){
perror("\n pstat_getprocvm");
break;
}
printf("\n type: %d, length: %d, phys pages: %d, ref count: %d",
pst.pst_type, pst.pst_length,
pst.pst_phys_pages, pst.pst_refcnt);
count2 = pstat_getpathname(name, 100, &pst.pst_fid);
if (count2 > 0) {
printf(" %s", name);
}
i++;
}
printf("\n");
}
4.18 pstat_getsem()
Synopsis:
int pstat_getsem(struct pst_seminfo *buf, size_t elemsize, size_t elemcount, int index);
Description:
This call provides information about System V semaphore sets. Each structure returned
describes one semaphore set on the system. For each instance data up to a maximum of elemsize
bytes are returned in the structs pst_seminfo pointed to by buf. The elemcount parameter
specifies the number of structs pst_seminfo that are available at buf. The index parameter
specifies the starting index within the context of System V semaphore sets. As a shortcut,