summaryrefslogtreecommitdiff
path: root/benchmark/process_loop.js
blob: 18cc1695640c3ff096e5ca1d3a6c4df703926b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var sys = require("sys"),
    childProcess = require("child_process");

function next (i) {
  if (i <= 0) return;

  var child = childProcess.spawn("echo", ["hello"]);

  child.stdout.addListener("data", function (chunk) {
    sys.print(chunk);
  });

  child.addListener("exit", function (code) {
    if (code != 0) process.exit(-1);
    next(i - 1);
  });
}

next(500);