Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

child.stdin 为什么不是 stream.Writable 的实例? ???

问题:

官方文档中说child.stdin是一个可写流,child.stdin也确实可以使用stream.Writable类的方法,例如,child.stdin.write(),具体详见我的另一个问题(开始理解错误,以为 ChildProcess 本质是一个 process,所以使用的方法和属性跟使用 process 是一样的)。
child.stdin之所以可以使用write()方法,难道不是因为他是stream.Writable类的实例吗?但是通过代码测试却返回false

相关代码:

var stream = require('stream');
var spawn = require('child_process').spawn;
// 使用子进程 执行 tail 命令,实时查看被添加到 my_file 文件中的内容。
var child = spawn('tail', ['-f', '/var/temp/my_file']);
console.log(child.stdin instanceof stream.Writable); //=>false
console.log(child.stdin instanceof stream.Readable); //=>true

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...