2017-08-31 106 views

回答

1

可以使孩子继承stdio,在这里你有一个工作示例(Linux)的:

const { spawn } = require('child_process') 
const shell = spawn('sh',[], { stdio: 'inherit' }) 
shell.on('close',(code)=>{console.log('[shell] terminated :',code)}) 

输出示例:

sh-4.4$ uname 
Linux 
sh-4.4$ exit 
exit 
[shell] terminated : 0 

记住用正确的替换sh地狱为您的平台要求

相关问题