This commit is contained in:
parent
5ae61a62e9
commit
71c82120d5
3 changed files with 9 additions and 6 deletions
|
@ -24,17 +24,20 @@ t.describe('kill', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('should succeed in killing tree', async function() {
|
t.test('should succeed in killing tree', async function() {
|
||||||
|
console.log()
|
||||||
worker = spawn('node', ['./test/kill/runner.mjs'])
|
worker = spawn('node', ['./test/kill/runner.mjs'])
|
||||||
assert.ok(worker.pid)
|
assert.ok(worker.pid)
|
||||||
|
|
||||||
// Give it some time to start
|
// Give it some time to start
|
||||||
await new Promise(res => {
|
await new Promise(res => {
|
||||||
worker.stdout.on('data', function(data) {
|
worker.stdout.on('data', function(data) {
|
||||||
if (data.toString().indexOf('primary') >= 0) res()
|
process.stdout.write(data)
|
||||||
|
if (data.toString().indexOf('secondary') >= 0) res()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return kill(worker.pid).then(function(pids) {
|
return kill(worker.pid).then(function(pids) {
|
||||||
|
console.log(pids)
|
||||||
assert.strictEqual(pids.size, 2)
|
assert.strictEqual(pids.size, 2)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
|
|
||||||
|
console.log('primary', process.pid)
|
||||||
|
|
||||||
let secondary = spawn('node', ['./test/kill/second_runner.mjs'])
|
let secondary = spawn('node', ['./test/kill/second_runner.mjs'])
|
||||||
|
|
||||||
secondary.stdout.on('data', function(data) {
|
secondary.stdout.on('data', function(data) {
|
||||||
process.stdout.write(data)
|
process.stdout.write(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('primary')
|
setInterval(function() { console.log('primary', process.pid) }, 100)
|
||||||
|
|
||||||
setInterval(function() { console.log('primary') }, 100)
|
|
|
@ -1,2 +1,2 @@
|
||||||
console.log('secondary')
|
console.log('secondary', process.pid)
|
||||||
setInterval(function() { console.log('secondary') }, 100)
|
setInterval(function() { console.log('secondary', process.pid) }, 100)
|
Loading…
Reference in a new issue