![]() |
![]() |
![]() |
return process information
#include <sys/kernel.h> #include <sys/psinfo.h> #include <sys/seginfo.h> pid_t qnx_psinfo( pid_t proc_pid, pid_t pid, struct _psinfo *psdata, unsigned segindex, struct _seginfo *segdata );
The qnx_psinfo() function returns information on a process pid from the process manager identified by proc_pid. If proc_pid is PROC_PID, then information on a process running on the current node is returned. If pid is zero, information on the calling process is returned.
The data is broken down into:
![]() |
The structures for psdata and segdata are quite large, so make sure the stack is large enough to hold them if they're placed there. |
To obtain information on a process on another node, you must establish a virtual circuit to the process manager on that node and pass the vid as proc_pid. For example,
vid = qnx_vc_attach( node, PROC_PID, 1000, 0 ); status = qnx_psinfo( vid, pid, &psdata, 0, 0 );
![]() |
If you ask for information on a process that doesn't exist, information for another process might be returned. You should always check that the structure member psdata.pid contains the pid that was requested. |
The _psinfo structure contains information for virtual circuits (VCs), proxies, or processes, as well as information common to all. To determine which type (union member) to use, look at the flags field of the _psinfo structure:
if (_psinfo.flags & _PPF_VID) { /* is a VC -- use un.vproc */ } else if (_psinfo.flags & _PPF_MID) { /* is a PROXY -- use un.mproc */ } else { /* is a PROCESS -- use un.proc */ }
The following fields from _psinfo are used no matter what type of information is returned:
The following fields in the proc union member are used for processes:
![]() |
The mxcount field is only 16 bits long. |
The following fields in the vproc union member apply to virtual circuits:
The following field in the mproc union member applies to proxies:
The _seginfo structure is defined with the qnx_segment_info() function. It contains at least the following members:
The parameter segdata must point to a buffer big enough to hold an array of 16 _seginfo structures. Memory on a process is maintained as a table of segments in the operating system. The segindex argument sets the starting point in the table to return information on.
int sindex; struct _psinfo psdata; struct _seginfo segdata[16]; for( sindex = 0; qnx_psinfo( PROC_PID, pid, &psdata, sindex, segdata ) != -1; sindex += 16 ) printf( "Number of selectors=%d\n", psdata.un.proc.nselectors );
![]() |
This function tries to guess how much "real" memory a segment uses, and adjusts nbytes accordingly. Use the qnx_segment_info() function to get the actual value. |
A process ID, or -1 if an error occurs. On error, errno is set.
#include <stdio.h> #include <sys/psinfo.h> struct _psinfo data; void main() { pid_t id; id = 1; while( ( id = qnx_psinfo( 0, id, &data, 0, 0 ) ) != -1 ) { if( ( data.flags & ( _PPF_MID|_PPF_VID ) ) == 0 ) printf( "%5d %s\n", id, data.un.proc.name ); ++id; } }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, qnx_osinfo(), qnx_segment_alloc(), qnx_segment_info(), qnx_vc_attach()
![]() |
![]() |
![]() |