qnx_psinfo

return process information

Synopsis:

#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 );

Description:

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 );
If you ask for information on a process that doesn't exist then information is returned on the next monotonically greater process. You should always check that the structure member psdata.pid contains the pid that was requested. This automatic search for the next existing process provides a convenient method of obtaining information on all system processes.

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 nbytesThe 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 structures for psdata and segdata are quite large, so care should be taken to make sure the stack is large enough to hold them if they are placed there.

Returns:

The function qnx_psinfo() returns a process id on success. On error, it returns (-1), and errno is set.

Errors:

EINVAL
No process with a process id >= pid exists.

See also:

errno, qnx_osinfo(), qnx_segment_alloc(), qnx_segment_info(), qnx_vc_attach()

Examples:

#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;
    }
  }

Classification:

QNX

Systems:

QNX