Skip to content

process

The process namespace provides access to current OS process parameters, child process execution, and process control. No import is required.


FunctionSignatureReturn TypeDescription
process.argsprocess.args()arrayReturns command-line arguments passed to the script.
process.exitprocess.exit(code = 0)neverTerminates the current process immediately with an exit code.
process.cwdprocess.cwd()stringReturns the current working directory path.
process.pidprocess.pid()numberReturns the unique operating system process ID.
process.runprocess.run(cmd)stringExecutes a shell command synchronously and returns its stdout.
process.exe_dirprocess.exe_dir()stringReturns the directory containing the running executable.

Returns an array of strings containing arguments passed after the script filename:

Terminal window
rqio run cli_tool.rq --input data.txt --verbose
var args = process.args();
print("Total arguments: " + str(len(args)));
var i = 0;
while (i < len(args)) {
print("Arg " + str(i) + ": " + args[i]);
i = i + 1;
}

Executes a command in the system shell and captures its text output:

var gitCommit = process.run("git rev-parse --short HEAD");
print("Current Git commit: " + gitCommit);

Immediately halts execution of the script and returns the status code to the OS:

var inputFile = "config.json";
if (!fs.exists(inputFile)) {
print("Error: Missing " + inputFile);
process.exit(1);
}

var pid = process.pid();
var dir = process.exe_dir();
print("Process ID: " + str(pid));
print("Binary directory: " + dir);