Terminating the current process and replacing it with another¶
chain |
Terminate the current process and replace it with another |
SYNTAX
chain text_expression
The chain command terminates the current program and replaces it with the process indicated by text_expression. When the new process terminates, control is returned to the parent of the current process.
text_expression |
The name of the new process. It may be a text constant, an alphanumeric field, or a concatenation of several such items. It should form the name of the program to be called, together with any arguments required by that program. |
Calling a new shell¶
The chain command does not call a new shell to process the program specified by text_expression. It merely replaces the current process in memory. However, if the command line represented by text_expression contains certain features, then a new shell must be called. These features are:
1 |
I/O redirection |
2 |
Pipes |
3 |
Shell expansion |
If any of these is required, the new shell or command processor must be explicitly chained, with the command to be executed passed to it as a parameter.
Using the chain command under Windows¶
There are two ways to use the chain command under Windows:
1 chain “program args…” |
Creates a DOS shell and executes the program as a DOS command. The parent program then exits. |
2 chain “-program args…” |
Creates a new Windows program, The parent program starts the child program and then exits. |
NOTES
The execute() function executes a child process and returns a handle to it.
The exec command is used to call another program as a child task, with control returning to the current program when the child task terminates.
The length of the command to be executed must not exceed operating system limits. On MS-DOS, the maximum length is 128 characters.
EXAMPLE
Chain a screen form program with an argument
chain "sagewc orders " + tmp.Number
Call a new shell, as redirection required
chain "sh -c srepwc calc pterm >/dev/tty" chain "command /c dir >dir.out"
RELATED TOPICS |