API Docs for:
Show:

ChildProcess Class

Constructor

ChildProcess

(
  • config
)

Parameters:

  • config Object

    Configuration object.

Methods

_write

(
  • data
  • encoding
)
private

Parameters:

kill

(
  • signal
)
chainable

Sends a signal to the child process. Refer to Node.js child.kill documentation. Note that while the method is called kill, the signal delivered to the child process may not actually kill it. kill really just sends a signal to a process.

Parameters:

  • signal String

    (optional) Defaults to 'SIGTERM'.

write

(
  • data
  • encoding
)
chainable

Writes data to the stdin of the child process. If the stdin of the child process has reported its kernel buffer is full, the write will be queued until the drain event.

Parameters:

  • data Buffer | String

    The data to write.

  • encoding String

    (optional) The encoding to use when data is a String value. May be one of 'ascii', 'base64', or 'utf8'. If undefined, 'utf8' is assumed.

Properties

_childProcess

Unknown protected

Attributes

args

Array

Array of command line arguments. Refer to Node.js child_process.spawn documentation.

Default: []

Fires event argsChange

Fires when the value for the configuration attribute args is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

command

String

The command to execute. Refer to Node.js child_process.spawn documentation.

Fires event commandChange

Fires when the value for the configuration attribute command is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

options

Object

Additional options. Refer to Node.js child_process.spawn documentation.

Default: {}

Fires event optionsChange

Fires when the value for the configuration attribute options is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

pid

Number

The PID of the child process.

Fires event pidChange

Fires when the value for the configuration attribute pid is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

ready

Boolean

This will be true when the stdin of the child process is writable and its kernel buffer is not full.

Default: false

Fires event readyChange

Fires when the value for the configuration attribute ready is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

stderrEncoding

String

Encoding may be one of 'ascii', 'base64', or 'utf8'. If left undefined, the stderr event will emit a Buffer instead of a string.

Fires event stderrEncodingChange

Fires when the value for the configuration attribute stderrEncoding is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

stdoutEncoding

String

Encoding may be one of 'ascii', 'base64', or 'utf8'. If left undefined, the stdout event will emit a Buffer instead of a string.

Fires event stdoutEncodingChange

Fires when the value for the configuration attribute stdoutEncoding is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

Events

drain

Fires when the stdin of the child process is writable again after having reported its kernel buffer was full.

error

Fires when there is an error in any stream of the child process.

Event Payload:

  • stderr Object

    Error reported from stderr.

  • stdin Object

    Error reported from stdin.

  • stdout Object

    Error reported from stdout.

exit

Fires when the child process exits.

Event Payload:

  • code Number | Null

    If the process terminated normally, code is the final exit code of the process, otherwise null.

  • signal String | Null

    If the process terminated due to receipt of a signal, signal is the string name of the signal, otherwise null.

stderr

Fired when stderr receives data.

Event Payload:

stdout

Fired when stdout receives data.

Event Payload: