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:
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 );
The _seginfo structure is defined with the qnx_segment_info() function. It contains at least the following members:
| Type | Member | Description |
|---|---|---|
| short unsigned | selector | The memory segment. |
| short unsigned | flags | The type of segment, using QNX's defined flags, not Intel's. |
| long | addr | The physical linear memory address where the segment starts. |
| long | nbytes | The size of the segment. |
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.nselectors );
The function qnx_psinfo() returns a process id on success. On error, it returns (-1), and errno is set.
errno, qnx_osinfo(), qnx_segment_alloc(), qnx_segment_info(), qnx_vc_attach()
#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
QNX