pstat.2 (2010 09)
p
pstat(2) pstat(2)
Example 8
Acquire information about a specific LWP.
main()
{
struct lwp_status lwpbuf;
int count;
/*
* get information for LWP whose lwpid is 4321 within
* a process whose pid is 1234.
*/
count = pstat_getlwp(&lwpbuf, sizeof(struct lwp_status),
0, 4321, 1234);
if ((count == -1) && (errno == ESRCH))
perror("pstat_getlwp(): cannot find given lwpid or pid");
else if (count == -1)
perror("pstat_getlwp()");
else {
/* process data from the call... */
(void)printf("processing lwp data...\n");
}
}
Example 9A
Acquire detailed information about a specific file.
main()
{
struct pst_fileinfo2 psf;
struct pst_filedetails psfdetails;
int count, fd;
(void)memset(&psf,0,sizeof(psf));
(void)memset(&psfdetails,0,sizeof(psfdetails));
fd = open("/stand/vmunix", O_RDONLY);
count = pstat_getfile2(&psf, sizeof(psf), 0, fd, getpid());
if (count == 1) {
count = pstat_getfiledetails(&psfdetails, sizeof(psfdetails),
&psf.psf_fid);
if (count == 1) {
if ((psfdetails.psfd_hi_fileid == psf.psf_hi_fileid) &&
(psfdetails.psfd_lo_fileid == psf.psf_lo_fileid) &&
(psfdetails.psfd_hi_nodeid == psf.psf_hi_nodeid) &&
(psfdetails.psfd_lo_nodeid == psf.psf_lo_nodeid)) {
printf("Success\n");
}
else {
printf("State changed\n");
}
}
else {
perror("pstat_getfiledetails()");
}
}
else {
perror("pstat_getfile2");
}
close(fd);
}
22 Hewlett-Packard Company − 22 − HP-UX 11i Version 3: September 2010