3
在下面的node.js代碼中,我通常必須等待phantomjs子進程終止以獲取stdout。我想知道在phantomjs子進程運行時是否有任何方法可以看到stdout?如何使用node.js查看phantomjs子進程的stdout?
var path = require('path')
var childProcess = require('child_process')
var phantomjs = require('phantomjs')
var binPath = phantomjs.path
var childArgs = [
path.join(__dirname, 'phantomjs-script.js'),
]
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
// handle results
})