search

Home  >  Q&A  >  body text

node.js - node exec 执行没反应

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}`);
          });

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

而在终端执行完全正常。

天蓬老师天蓬老师2866 days ago918

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 15:40:32

    The default maximum allowed amount of data output to stdout and stderr by exec does not exceed 200K. If it exceeds, the child process will be killed.

    Here, let me give you a door https://segmentfault.com/q/10...

    reply
    0
  • Cancelreply