2009-10-30 06:34:10 +08:00
|
|
|
process.mixin(require("common.js"));
|
2009-06-27 05:42:06 +08:00
|
|
|
|
|
|
|
var N = 40;
|
|
|
|
var finished = false;
|
|
|
|
|
|
|
|
function spawn (i) {
|
2009-10-30 06:34:10 +08:00
|
|
|
var child = process.createChildProcess( 'python'
|
2009-10-07 07:04:27 +08:00
|
|
|
, ['-c', 'print 500 * 1024 * "C"']
|
|
|
|
);
|
2009-06-27 05:42:06 +08:00
|
|
|
var output = "";
|
|
|
|
|
2009-08-27 04:11:51 +08:00
|
|
|
child.addListener("output", function(chunk) {
|
2009-06-27 05:42:06 +08:00
|
|
|
if (chunk) output += chunk;
|
2009-08-27 04:03:19 +08:00
|
|
|
});
|
2009-06-27 05:42:06 +08:00
|
|
|
|
2009-10-07 07:04:27 +08:00
|
|
|
child.addListener("error", function(chunk) {
|
|
|
|
if (chunk) error(chunk)
|
|
|
|
});
|
|
|
|
|
2009-08-27 04:11:51 +08:00
|
|
|
child.addListener("exit", function () {
|
2009-10-07 07:04:27 +08:00
|
|
|
puts(output);
|
2009-06-27 05:42:06 +08:00
|
|
|
if (i < N)
|
|
|
|
spawn(i+1);
|
|
|
|
else
|
|
|
|
finished = true;
|
2009-06-28 02:40:43 +08:00
|
|
|
});
|
2009-06-27 05:42:06 +08:00
|
|
|
}
|
|
|
|
|
2009-08-27 00:22:00 +08:00
|
|
|
spawn(0);
|
2009-06-27 05:42:06 +08:00
|
|
|
|
2009-08-27 00:51:04 +08:00
|
|
|
process.addListener("exit", function () {
|
2009-06-27 05:42:06 +08:00
|
|
|
assertTrue(finished);
|
2009-08-27 00:51:04 +08:00
|
|
|
});
|