按照node入门做到一个demo有点儿不对,麻烦看下.
发布于 10 年前 作者 firhome 3657 次浏览 最后一次编辑是 8 年前

exec(“dir”, { timeout: 10000, maxBuffer: 20000 * 1024 }, function(error, stdout, stderr) {

});

为何此处 {

timeout: 10000,

maxBuffer: 20000 * 1024

}

无效?

1 回复

RE:请给出具体例子地址

timeout:进程超时时间

maxBuffer:stdout或stderr可增长的最大值

var exec = require(‘child_process’).exec, child;

child = exec(

‘dir’,

{ timeout : 10000, cwd : ‘…/’ },

function (error, stdout, stderr) { console.log(‘stdout: \n’ + stdout); console.log(‘stderr: \n’ + stderr); if (error !== null) { console.log('exec error: ’ + error); }

});

cwd设置成功,判断里面的参数应该是有效的

回到顶部