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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745497807a4630271.html
评论列表(0条)