Socket
Socket
Sign inDemoInstall

foreground-child

Package Overview
Dependencies
1
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

80

index.js

@@ -0,1 +1,4 @@

var signalExit = require('signal-exit')
var spawn = require('child_process').spawn
module.exports = function (program, args) {

@@ -9,33 +12,21 @@ if (Array.isArray(program)) {

var child = require('child_process').spawn(
program,
args,
{ stdio: 'inherit' }
)
var child = spawn(program, args, { stdio: 'inherit' })
signals.forEach(function (sig) {
try {
process.on(sig, function () {
child.kill(sig)
})
} catch (er) {}
var childExited = false
signalExit(function (code, signal) {
child.kill(signal || 'SIGHUP')
})
process.once('exit', function (code) {
emittedExit = true
child.kill('SIGHUP')
})
var emittedExit = false
child.on('close', function (code, signal) {
childExited = true
if (signal) {
process.removeAllListeners(signal)
if (!emittedExit) {
process.emit('exit', code)
}
// If there is nothing else keeping the event loop alive,
// then there's a race between a graceful exit and getting
// the signal to this process. Put this timeout here to
// make sure we're still alive to get the signal, and thus
// exit with the intended signal code.
setTimeout(function () {}, 200)
process.kill(process.pid, signal)
} else {
} else
process.exit(code)
}
})

@@ -45,42 +36,1 @@

}
var signals = [
'SIGABRT',
'SIGALRM',
'SIGBUS',
'SIGCHLD',
'SIGCLD',
'SIGCONT',
'SIGEMT',
'SIGFPE',
'SIGHUP',
'SIGILL',
'SIGINFO',
'SIGINT',
'SIGIO',
'SIGIOT',
'SIGKILL',
'SIGLOST',
'SIGPIPE',
'SIGPOLL',
'SIGPROF',
'SIGPWR',
'SIGQUIT',
'SIGSEGV',
'SIGSTKFLT',
'SIGSTOP',
'SIGSYS',
'SIGTERM',
'SIGTRAP',
'SIGTSTP',
'SIGTTIN',
'SIGTTOU',
'SIGUNUSED',
'SIGURG',
'SIGUSR1',
'SIGUSR2',
'SIGVTALRM',
'SIGWINCH',
'SIGXCPU',
'SIGXFSZ'
]

6

package.json
{
"name": "foreground-child",
"version": "1.1.0",
"version": "1.2.0",
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",

@@ -9,3 +9,5 @@ "main": "index.js",

},
"dependencies": {},
"dependencies": {
"signal-exit": "^2.0.0"
},
"devDependencies": {

@@ -12,0 +14,0 @@ "tap": "^1.0.4"

var fg = require('../index.js')
var spawn = require('child_process').spawn
var signalExit = require('signal-exit')

@@ -29,3 +30,3 @@ if (process.argv[2] === 'child') {

if (process.argv[3] === 'signalexit') {
process.on('exit', function () {
signalExit(function (code, signal) {
console.log('parent exit')

@@ -32,0 +33,0 @@ })

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