Socket
Socket
Sign inDemoInstall

foreground-child

Package Overview
Dependencies
2
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    foreground-child

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


Version published
Weekly downloads
21M
decreased by-17.47%
Maintainers
1
Install size
128 kB
Created
Weekly downloads
 

Package description

What is foreground-child?

The foreground-child npm package is used to run a child process in the foreground, ensuring that signals such as SIGINT, SIGTERM, and exit codes are properly forwarded from the child process to the parent. This is particularly useful when you want to ensure that a child process is treated as if it were the main process, especially in the context of command-line tools and scripts.

What are foreground-child's main functionalities?

Running a child process in the foreground

This feature allows you to run a child process as if it were the main process. The code sample demonstrates how to use foreground-child to run a Node.js script in the foreground.

const foregroundChild = require('foreground-child');

const cmd = 'node';
const args = ['my-script.js'];
foregroundChild(cmd, args);

Other packages similar to foreground-child

Changelog

Source

v1.3.3

  • Skip signals in tests on Windows
  • update to tap@4
  • use cross-spawn-async on windows

Readme

Source

foreground-child

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()
})

FAQs

Last updated on 02 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc