$PSTAT
The $PSTAT statement is used to return status information for the specified partition. The first 8 bytes of $PSTAT may be changed with the first form.
Specifying no numeric expression for the second form of $PSTAT is the same as entering STR($PSTAT(#PART),,8).
Byte | Description |
---|---|
1-8 | User specified status as set by the $PSTAT statement. |
9 | Always 'K' for KCML. |
10 | KCML release, HEX(30) for release 3.0, HEX(31) for release 3.1, HEX(32) for release 3.2 etc. |
11 | Not used, always HEX(30). |
12-13 | Partition size, current value of the SPACEK environment variable or HEX(9999) if not set. |
14 | Programmability, 'P' if programmable (the default), ' ' if NOPROG environment variable is set. |
15 | BCD terminal number, Always BCD HEX(99) for terminal 99 and above. See bytes 41-42 for true terminal number. |
16 | Terminal status `A' if attached, 'D' if detached, 'W' if waiting to attach, 'F' if a suspended $RELEASE parent. |
17-24 | Global name, all HEX(00) if no DEFFN @PART is executed. |
25 | ERR function value, numeric code from last error whether trapped or not, else HEX(00). The subscript error code is stored in byte 49. |
26 | BCD text partition number. The partition number of the text currently being executed. Always BCD, HEX(99) for partition 99 and above. See bytes 43-44 for true text partition. For KCML 6.0+ this is always set to #PART. |
27 | BCD global partition number of the text currently selected in a SELECT @PART. Always BCD, HEX(99) for partition 99 and above. See bytes 45-46 for the true global partition number. |
28 | BCD DATA partition number. Partition number containing the current RESTORE pointer. This will only be different from #PART if a RESTORE was executed in global text. Always BCD, HEX(99) for partition 99 and above. See bytes 47-48 for the true DATA partition number. |
29 | DEVice awaited: HEX(00) while executing - the partition will not respond to the PANIC CONTINUE or snoop signals. HEX(01) if awaiting a keystroke. HEX(FF) if blocked on $OPEN of a native file. HEX(FD) if waiting on $IF or 'KCML_poll(). HEX(FC) if executing a SHELL statement. HEX(FB) if executing a $BREAK statement. HEX(FA) if waiting for a request when acting as a SOAP server. Any other value should be interpreted as a device address from $DEVICE. |
30-36 | User's login name. Truncated if longer than 7 bytes. Full usernames are displayed by the WebServer . |
37-40 | Process id, four byte binary. |
41-42 | #TERM in binary (supersedes byte 15). |
43-44 | Executing partition in binary (supersedes byte 26). For KCML 6.0+ this is always set to #PART. |
45-46 | Selected global partition in binary (supersedes byte 27). |
47-48 | DATA partition in binary (supersedes byte 28). |
49 | The subscript code for the last error (See byte 25.) |
50-68 | Reserved |
69-72 | IP address of WDW clients. For generic code use bytes 49-52 of $MACHINE. |
73-74 | dynamic heap size in Kb. Only accurate upto 64Mb. For larger heap sizes use the PSTAT_HeapSize2 field of the KCML_PSTAT build in DEFRECORD |
75 | client category, 'T' licensed for text only 'F' licenced for forms 'N' not applicable 'G' memory mapped global pseudo partition 'B' batch program, executed with the -p switch 'W' SOAP server that is using a [SOAP] licence |
76-91 | Client computer name, if supplied by client program (null terminated string) |
92 | Reserved |
93-96 | $TIME format timestamp of last keyboard activity or, for a SOAP server, the last request. This value is not set for background partitions. |
97-104 | Reserved |
105-110* | Client PC's MAC/Ethernet card address, 6-byte binary value |
111-128 | Reserved |
$PSTAT as a record
From version 06.20, KCML defines a KCML_PSTAT built in DEFRECORD that can be used to access the fields in $PSTAT e.g.
pid = FLD($PSTAT(#PART).PSTAT_ProcessId)
Compatibility notes
The extra fields from byte 50 onwards were introduced with KCML 6.0. Because of support for memory mapped globals and for libraries KCML 6.0+ no longer tracks the executing partition in bytes 43 and 44. If a SELECT@PART for a process global is in effect then bytes 45-46 will be set to the global's partition number but if the SELECT @PART referred to a memory mapped global then this field will be set to #PART. Similarly the DATA partition will only be set for a process global. These fields should be considered obsolete and should not be used.
The size of $PSTAT was increased to 128 bytes with build 9351 of KCML 6.0+.
KCML 6.20.73 & 7.05 allow the size of a partition to be increased the existance of /etc/kcml/pstat_X. The width of a partition is 2X, so for /etc/kcml/pstat_8, the width of partition is 28 = 256 bytes.
This value is also stored in byte 64 of $MACHINE.
The userid field was originally limited to the first 7 characters. From KCML 6.00 onward 16 character names were recorded but only the first 7 were available using the $PSTAT() function. When the DEFRECORD describing $PSTAT was introduced with KCML 6.40 then whole 16 characters were made available to the application.
DIM ps$_KCML_PSTAT DIM username$16 ps$ = $PSTAT(#PART) username$ = FLD(ps$.PSTAT_UserId$)
Syntax examples:
$PSTAT = user_message$
partition$ = $PSTAT
pt$ = STR($PSTAT,,3)
See also:
Configuring $PSTAT, $SYSTEMID, $KCML_PSTAT_SIZE, bkstat, Web Administration Tool, Internal structures