K
K
krll-k2016-12-27 00:39:22
JavaScript
krll-k, 2016-12-27 00:39:22

How to run a process in a loop in javascript?

I have code:

var exec = require('child_process').exec;
var cmd = exec('somethingProccess');

//cmd.stdout.on('data', function(data) {
//    console.log(data); 
//});

cmd.stdout.pipe(process.stdout);
So I can't do it:
while(1==1){
cmd.stdout.pipe(process.stdout)
}
, because the process will run second and third parallel to the first. I need the second process to start only after the first one finishes, the second ... like the third, and so on ....
I need to start the process immediately after it has finished, any ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arman, 2016-12-27
@Arik

exec() - 3 argument callback?

S
Schoolboy., 2016-12-27
@viphorizon

Look at async and promise

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question