Tuesday, 4 April 2017

How ctrl+c and ctrl+d trigger the stdout 'data' event of a spawn child process?

const { spawn } = require('child_process')

const child = spawn('wc')

process.stdin.pipe(child.stdin)

child.stdout.on('data', (data) => {
    console.log(`child stdout:\n ${data}`)
})

The child.stdout.on('data'... will execute when pressing ctrl+d under parent process ,
Why not ctrl+c ?



via stackoverYC

No comments:

Post a Comment