Skip to content

process

This content is for v0.2.1. Switch to the latest version for up-to-date documentation.

The process namespace provides access to current OS process parameters and control.


FunctionSignatureReturn TypeDescription
process.argsprocess.args()arrayReturns command-line arguments passed to the script.
process.exitprocess.exit(code)neverTerminates the current process immediately with an exit code.
process.cwdprocess.cwd()stringReturns the current working directory path.
process.pidprocess.pid()numberReturns the unique process ID.
process.chdirprocess.chdir(dir)boolChanges the current working directory.

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;
}

Immediately halts execution of the script or compiled binary and returns the specified integer status code to the operating system.

  • 0: Success / normal exit.
  • 1 or greater: Error / abnormal exit.
var input_file = "data.csv";
if (!fs.exists(input_file)) {
print("Error: Missing input file " + input_file);
process.exit(1);
}

Returns an absolute path representing the process’s current working directory.

var current_dir = process.cwd();
print("Working in: " + current_dir);

Returns the operating system Process ID (PID), useful for logging, creating lockfiles, or process supervision.

var pid = process.pid();
print("Process ID: " + str(pid));
fs.write("server.pid", str(pid));