Caché ObjectScript Reference
$JOB
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Contains the ID of the current process.
Synopsis
$JOB
$J
Description
$JOB contains the ID number of the current process. This ID number is the host operating system’s actual Process ID (pid). This ID number is unique for each process.
The ID number for an I/O process (such as a Caché terminal process) is part of the string contained in the $IO special variable.
The format of the string returned to $JOB is determined for the current process by the setting of the NodeNameInPid() method of the %SYSTEM.Process class. The system-wide default behavior can be established by setting the NodeNameInPid property of the Config.Miscellaneous class. By default $JOB returns only the 10-digit pid, but you can set these functions to have $JOB return both the pid and the node name. If you change the setting of this switch, you must recompile any routines that use the string returned to $JOB in arithmetic operations where $JOB is converted to an integer.
This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.
To return the pid as the terminal prompt, use the TerminalPrompt(5) method of the %SYSTEM.Process class.
Other Information About the Current Process
You can obtain the same current process ID number by invoking the ProcessId() method, as follows:
   WRITE $SYSTEM.SYS.ProcessID()
 
Refer to the %SYSTEM.SYS class in the InterSystems Class Reference for further details.
You can use $JOB to obtain the job number for the current process as follows:
   ZNSPACE "%SYS"
   SET Job=##class(SYS.Process).%OpenId($JOB)
   WRITE Job.JobNumber
 
This example requires that UnknownUser have assigned the %DB_CACHESYS role.
Refer to the SYS.Process class in the InterSystems Class Reference for further details.
You can obtain status information about the current process from the $ZJOB special variable.
You can obtain the pid of the child process or the parent process of the current process from the $ZCHILD and $ZPARENT special variables.
You can obtain the pids of the current jobs in the job table from the ^$JOB structured system variable.
See Also