您的位置:首页技术文章
文章详情页

node.js - node exec 执行没反应

浏览:67日期:2024-07-28 11:46:36

问题描述

const exec = require(’child_process’).exec; exec(’cat /dev/urandom |od -x|head -n 1’, (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`); return; } console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); });

为什么执行这段语句,完全没反应?

而在终端执行完全正常。node.js - node exec 执行没反应

问题解答

回答1:

exec的默认的最大允许输出到stdout和stderr的数据量不超过200K,如果超过了,子进程就会被杀死。

来,给你一个门 https://segmentfault.com/q/10...

相关文章: