Product Documentation
Cadence Interprocess Communication SKILL Reference
Product Version IC23.1, June 2023

ipcBeginProcess

ipcBeginProcess( 
t_command 
[ t_hostName ] 
[ tsu_dataHandler ] 
[ tsu_errHandler ] 
[ tsu_postFunc ] 
[ t_logFile ] 
) 
=> o_childId

Description

Invokes a process to execute a command or sequence of commands specified.

The commands are executed locally or on a network node as specified by the argument hostName. The newly initiated child process communicates with its parent process using the standard descriptors, stdin, stdout and stderr, as the main input and output channels. Data written by the child into stdout and stderr is received by the parent, and data sent by the parent is written into the child’s stdin.

With the exception of the command string, the parameters passed to ipcBeginProcess are optional.

The call back arguments (data handlers and post function) can be given as symbols, strings or function objects.

The maximum number of child processes is limited by the system resources and a warning message displays when the fileDescriptor limit is exceeded.

Arguments

t_command

Command to be executed locally or on a network node.

t_hostName

Specifies the network node. An empty string ("") for hostName means the process is run locally.

tsu_dataHandler, tsu_errHandler, tsu_postFunc

These call back functions can be given as strings, symbols or function objects. Handlers are called whenever the parent process receives data from the child process. Activation of handler calls occurs at the top level of SKILL; that is, it does not interrupt the current evaluation. Define handlers to accept two parameters: o_childId and t_data. Handlers are called with the childId of the child that sent the data and the data itself is packed into a SKILL string.

If tsu_dataHandler is nil, the data received from the child is buffered for a ipcReadProcess call. The parent must use ipcReadProcess to read the data.

tsu_dataHandler, tsu_errHandler correspond to a child’s stdout and stderr respectively.

The tsu_postFunc function is called when a child terminates. It must be defined to accept two parameters: o_childId and x_exitStatus, where exitStatus is the value returned by the child process on exit. If tsu_postFunc is nil, the child process’s state and exit status must be checked using the ipcIsAliveProcess or ipcWait and ipcGetExitStatus functions (or use the state and exitStatus handle properties).

t_logFile

File that can be used to log all output from a child process. If logFile is an empty string, the child process cannot be switched to batch mode and its output is always sent to the parent.

A child invoked with the t_logFile present starts its life duplicating its output to the log file and sending the data to the parent. If at any point the child is to be put in batch mode and its communications with the parent silenced, use ipcActivateBatch. Once in batch mode, the output of a child process is written to the logFile only. Subsequently, the messages to the parent can be turned back on using ipcActivateMessages. Using these two functions, a child process can be made to switch between the batch and active data passing states.

Value Returned

o_childId

Your handle on the child process. All operations performed on a child process need o_childId. The value of o_childId is not meaningful to the underlying operating system. System calls, therefore, cannot use this value.

The shell commands executed by the child process do not require special modification to be invoked under SKILL. Their input and output streams function the same way as they do when invoked from a shell. For example, if the child process tries to read from its stdin and there is no data currently available, the read operation blocks until data becomes available.

Examples

      cid = ipcBeginProcess("hostname")
ipc:5
ipcReadProcess(cid)
"foghorn\n"
   handler = (lambda (cid data) printf("\n Hostname:%s\n" data))
funobj:0x2848e8
cid = ipcBeginProcess("hostname" "" handler)
ipc:6
Hostname: foghorn

Single quotation marks can be used to enclose a group of characters which should be treated as a single word without shell interpretation of special characters.

ipcBeginProcess("grep '> is a greater' /tmp/temp_ipcfile")

Do not use single quotation marks for grouping commands that need to be run locally.

cid = ipcBeginProcess("cd /tmp; ls -l temp_ipcfile")
ipc:7
cid = ipcBeginProcess("'cd /tmp; ls -l temp_ipcfile'" "someHost")
ipc:8

Related Topics

Interprocess Communication Functions

ipcActivateBatch

ipcBatchProcess

ipcSkillProcess


Return to top
 ⠀
X