ProcessAPI

interface ProcessAPI : NodeAPI, ProxyObject

Node API: Process

Describes the "process" object, as specified by the Node JS "process" built-in module. The "process" object provides information about the current process, and allows the user to interact with the process environment. This includes such information as the process' environment variable access, current working directory, process ID, and so on.

 

Summary

The process module is special in that it is both a module and a globally-available VM intrinsic; running under pure Node, one does not need to import or require anything at all and can just specify process.x. Additionally, the process module is made available as a standard built-in module. Elide supports both use styles.

 

Behavior

Depending on the access rights in the current environment, the process object behaves roughly the same in Elide as it does in Node. Where values are forbidden for access or otherwise unavailable, sensible values are provided instead of their real counterparts (for example, -1 as the process ID).

Behavior and requisite access rights are described below for each property, along with any other applicable behavior:

  • process.env: The environment variables of the current process. This is a read-only property. The values provided as "process environment" may be the real host environment or stubbed values, or both, and may include values from .env files loaded on behalf of the user. By default, host environment access is not available to guests in Elide.

  • process.argv: The command-line arguments of the current process. This is a read-only property. The values provided here are available when a JavaScript file is used as the program entrypoint, and under normal operating circumstances, even if the entrypoint is implemented in another language. Thus, the first argument to argv is always the Elide binary. In some circumstances, for example, render-only scripts, no arguments are available.

  • process.exit(code): Exit the current process with the specified exit code. This method is available to all guests and will, by default, exit the entire VM, including the host context; if VM exit is disabled or forbidden, this method halts guest execution and returns control to the host.

  • process.nextTick(callback, ...args): Schedule a callback to be invoked in the next tick of the event loop. This method is not implemented in Elide at the time of this writing.

 

See the Node Process API for more information.

See also

for details about how Elide handles Node-style environment access.

Properties

Link copied to clipboard
abstract val arch: String

Access the current architecture; this describes the CPU type in use.

Link copied to clipboard
abstract val argv: Array<String>

Access the command-line arguments of the current process.

Link copied to clipboard

Access the environment variables of the current process.

Link copied to clipboard
abstract val pid: Long

Access the process ID of the current process.

Link copied to clipboard
abstract val platform: String

Access the current operating platform; this describes the operating system in use.

Link copied to clipboard

Access to a stream for emitting content to stderr.

Link copied to clipboard

Access to a stream for consuming content from stdin.

Link copied to clipboard

Access to a stream for emitting content to stdout.

Link copied to clipboard
abstract var title: String?

Access to retrieve the current process title.

Functions

Link copied to clipboard
abstract fun cwd(): String

Access the current working directory of the current process.

Link copied to clipboard
abstract fun exit()

Exit the current process with the specified exit code; uses code 0.

abstract fun exit(code: Int?)

Exit the current process with the specified exit code. This variant works on a host exit code Int.

abstract fun exit(code: Value?)

Exit the current process with the specified exit code. This variant works on a guest Value.

Link copied to clipboard
abstract fun getMember(key: String): Any
Link copied to clipboard
open override fun getMemberKeys(): Array<String>
Link copied to clipboard
open override fun hasMember(key: String): Boolean
Link copied to clipboard
abstract fun nextTick(callback: (args: Array<Any>) -> Unit, vararg args: Any)

Schedule a callback to be invoked in the next tick of the event loop.

Link copied to clipboard
open override fun putMember(key: String, value: Value?)
Link copied to clipboard
open override fun removeMember(key: String?): Boolean