foreground-child

WebJar for foreground-child

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

foreground-child
Last Version

Last Version

1.5.6
Release Date

Release Date

Type

Type

jar
Description

Description

foreground-child
WebJar for foreground-child
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/tapjs/foreground-child

Download foreground-child

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/foreground-child/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>foreground-child</artifactId>
    <version>1.5.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/foreground-child/
implementation 'org.webjars.npm:foreground-child:1.5.6'
// https://jarcasting.com/artifacts/org.webjars.npm/foreground-child/
implementation ("org.webjars.npm:foreground-child:1.5.6")
'org.webjars.npm:foreground-child:jar:1.5.6'
<dependency org="org.webjars.npm" name="foreground-child" rev="1.5.6">
  <artifact name="foreground-child" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='foreground-child', version='1.5.6')
)
libraryDependencies += "org.webjars.npm" % "foreground-child" % "1.5.6"
[org.webjars.npm/foreground-child "1.5.6"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : cross-spawn jar [4.0.0,5)
org.webjars.npm : signal-exit jar [3.0.0,4)

Project Modules

There are no modules declared in this project.

foreground-child

Build Status Build status

Run a child as if it's the foreground process. Give it stdio. Exit when it exits.

Mostly this module is here to support some use cases around wrapping child processes for test coverage and such.

USAGE

var foreground = require('foreground-child')

// cats out this file
var child = foreground('cat', [__filename])

// At this point, it's best to just do nothing else.
// return or whatever.
// If the child gets a signal, or just exits, then this
// parent process will exit in the same way.

A callback can optionally be provided, if you want to perform an action before your foreground-child exits:

var child = foreground('cat', [__filename], function (done) {
  // perform an action.
  return done()
})

The callback can return a Promise instead of calling done:

var child = foreground('cat', [__filename], async function () {
  // perform an action.
})

The callback must not throw or reject.

Caveats

The "normal" standard IO file descriptors (0, 1, and 2 for stdin, stdout, and stderr respectively) are shared with the child process. Additionally, if there is an IPC channel set up in the parent, then messages are proxied to the child on file descriptor 3.

However, in Node, it's possible to also map arbitrary file descriptors into a child process. In these cases, foreground-child will not map the file descriptors into the child. If file descriptors 0, 1, or 2 are used for the IPC channel, then strange behavior may happen (like printing IPC messages to stderr, for example).

Note that a SIGKILL will always kill the parent process, and never the child process, because SIGKILL cannot be caught or proxied. The only way to do this would be if Node provided a way to truly exec a process as the new foreground program in the same process space, without forking a separate child process.

org.webjars.npm

TAP in JavaScript

An organization to house node-tap and friends

Versions

Version
1.5.6