如何在Firefox Add-on SDK中将数据写入child_process的stdin?

时间:2015-12-17 21:24:24

标签: firefox-addon firefox-addon-sdk

child_process模块实现child_process Add-on SDK docsthe node.js child_process API状态。所以,我正在尝试生成子流程并将数据写入其中,如the node.js docs section covering the spawn method中所述:

var child_process = require("sdk/system/child_process");

var doiuse = child_process.spawn("/usr/local/bin/doiuse");
doiuse.stdin.write(data);

但是我收到了这个错误:

TypeError: doiuse.stdin.write is not a function

那么,如何在Firefox Add-on SDK中写入子进程?

1 个答案:

答案 0 :(得分:1)

#jetpack IRC channel中,建议使用the child_process tests之类的代码。所以,我得到了它:

const { emit } = require('sdk/event/core');
const { spawn } = require('sdk/system/child_process');

var proc = spawn("/bin/cat");

emit(proc.stdin, 'data', "Hello from Add-on code");
emit(proc.stdin, 'end');