z/OS Using REXX and z/OS UNIX System Services
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


getpsent

z/OS Using REXX and z/OS UNIX System Services
SA23-2283-00

Read syntax diagramSkip visual syntax diagram
>>-getpsent--stem----------------------------------------------><

Function

getpsent invokes the w_getpsent callable service to provide data describing the status of all the processes to which you are authorized. The data is formatted in a stem. The PS_ variables, or their numeric equivalents, are used to access the fields.

Parameters

stem
Upon return, stem.0 contains the number of processes for which information is returned. stem.1 through stem.n (where n is the number of entries returned) each contain process information for the nth process.
You can use the predefined variables that begin with PS_ or their equivalent numeric values (see REXX predefined variables) to access the information. For example, stem.1.ps_pid is the process ID for the first process returned.
Variable Description
PS_CMD Command
PS_CONTTY Controlling tty
PS_EGID Effective group ID
PS_EUID Effective user ID
PS_FGPID Foreground process group ID
PS_MAXVNODES Maximum number of vnode tokens allowed
PS_PATH Pathname
PS_PGPID Process Group ID
PS_PID Process ID
PS_PPID Parent Process ID
PS_RGID Real group ID
PS_RUID Real user ID
PS_SERVERFLAGS Server flags
PS_SERVERNAME Server name supplied on registration
PS_SERVERTYPE Server type (File=1; Lock=2)
PS_SGID Saved set group ID
PS_SID Session ID (leader)
PS_SIZE Total size
PS_STARTTIME Starting time, in POSIX format (seconds since the Epoch, 00:00:00 on 1 January 1970)
PS_STAT Process status
PS_STATE Process state This value can be expressed as one of the following predefined variables or as an alphabetic value (see REXX predefined variables):
PS_CHILD
Waiting for a child process
PS_FORK
fork() a new process
PS_FREEZE
QUIESCEFREEZE
PS_MSGRCV
IPC MSGRCV WAIT
PS_MSGSND
IPC MSGSND WAIT
PS_PAUSE
MVSPAUSE
PS_QUIESCE
Quiesce termination wait
PS_RUN
Running, not in kernel wait
PS_SEMWT
IPC SEMOP WAIT
PS_SLEEP
sleep() issued
PS_WAITC
Communication kernel wait
PS_WAITF
File system kernel wait
PS_WAITO
Other kernel wait
PS_ZOMBIE
Process cancelled
PS_ZOMBIE2
Process terminated yet still the session or process group leader
PS_SUID Saved set user ID
PS_SYSTIME System CPU time, a value of the type clock_t, which needs to be divided by sysconf(_SC_CLK_TCK) to convert it to seconds. For z/OS UNIX, this value is expressed in hundredths of a second.
PS_USERTIME User CPU time, a value of the type clock_t, which needs to be divided by sysconf(_SC_CLK_TCK) to convert it to seconds. For z/OS UNIX, this value is expressed in hundredths of a second.
PS_VNODECOUNT The current number of vnode tokens

Usage notes

  1. Information is returned for only those processes for which RACF® allows the user access based on effective user ID, real user ID, or saved set user ID.
  2. PS_STARTTIME is in seconds since the Epoch (00:00:00 on 1 January 1970).
  3. PS_USERTIME and PS_SYSTIME are task-elapsed times in 1/100ths of seconds.
  4. PS_SYSTIME reports the system CPU time consumed for the address space that the process is running in. When only one process is running in the address space, this time represents the accumulated system CPU time for that process. However, when more than one process is running in an address space, the information that is returned is actually the accumulated system CPU time consumed by all of the work running in the address space.

Example

This exec will produce output similar to the ps -A shell command, displaying information on all accessible processes:
/* rexx */
address syscall
say right('PID',12) left('TTY',10) '    TIME' 'COMMAND'
ps.0=0
'getpsent ps.'                         /* get process data            */
do i=1 to ps.0                         /* process each entry returned */
   t=(ps.i.ps_usertime + 50) % 100     /* change time to seconds      */
   'gmtime (t) gm.'                    /* convert to usable format    */
   if gm.tm_hour=0 then                /* set hours: samp ignores day */
      h='   '
    else
      h=right(gm.tm_hour,2,0)':'
   m=right(gm.tm_min,2,0)':'           /* set minutes                 */
   parse value reverse(ps.i.ps_contty),
         with tty '/'                  /* get tty filename            */
   tty=reverse(tty)
   say right(ps.i.ps_pid,12),          /* display process id          */
   say right(ps.i.ps_pid,12),          /* display process id          */
       left(tty,10),                   /* display controlling tty     */
       h || m || right(gm.tm_sec,2,0), /* display process time        */
       ps.i.ps_cmd                     /* display command             */
end
return 0

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014