admin管理员组文章数量:1430750
Here is the code i wrote,when i execute the code,the terminal didn't output anything and the program is blocked
var util=require('util')
var exec=require('child_process').exec;
exec('iostat 5',function(err,stdout,stderr){
util.puts("hello")
util.puts(stdout)
})
If i change the exec mand like this: it works and outputs the file list
var util=require('util')
var exec=require('child_process').exec;
exec('ls -al',function(err,stdout,stderr){
util.puts("hello")
util.puts(stdout)
})
is there any diffent between a block mand(iostat) and nonbolck mand(ls)?
Here is the code i wrote,when i execute the code,the terminal didn't output anything and the program is blocked
var util=require('util')
var exec=require('child_process').exec;
exec('iostat 5',function(err,stdout,stderr){
util.puts("hello")
util.puts(stdout)
})
If i change the exec mand like this: it works and outputs the file list
var util=require('util')
var exec=require('child_process').exec;
exec('ls -al',function(err,stdout,stderr){
util.puts("hello")
util.puts(stdout)
})
is there any diffent between a block mand(iostat) and nonbolck mand(ls)?
Share Improve this question edited Apr 8, 2012 at 9:06 drifting asked Apr 8, 2012 at 9:04 driftingdrifting 711 gold badge2 silver badges5 bronze badges1 Answer
Reset to default 2iostat 5
loops forever every 5 seconds and never terminates, so your exec callback will never be called. Instead you could call iostat
from a setInterval
call, or just remove the 5
if you only need it once.
本文标签: javascriptprocessexec() in nodejsStack Overflow
版权声明:本文标题:javascript - process.exec() in node.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745497806a2660887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论