summaryrefslogtreecommitdiff
path: root/test/pummel/test-process-spawn-loop.js
blob: 9a639ee9f1662558ccabec53a9508dcd07e8c219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
process.mixin(require("../common"));

var N = 40;
var finished = false;

function spawn (i) {
  var child = process.createChildProcess( 'python'
                                     , ['-c', 'print 500 * 1024 * "C"']
                                     );
  var output = "";

  child.addListener("output", function(chunk) {
    if (chunk) output += chunk;
  });

  child.addListener("error", function(chunk) {
    if (chunk) error(chunk)
  });

  child.addListener("exit", function () {
    puts(output);
    if (i < N)
      spawn(i+1);
    else
      finished = true;
  });
}

spawn(0);

process.addListener("exit", function () {
  assert.equal(true, finished);
});