parent.js 438 B

1234567891011121314151617
  1. var spawn = require('child_process').spawn;
  2. function loop() {
  3. console.log('starting');
  4. console.log(this);
  5. //var child = spawn('./node_modules/nodeunit/bin/nodeunit', ['test']);
  6. var child = spawn('node', ['child.js']);
  7. child.stdout.on('data', function(buffer) {
  8. process.stdout.write(buffer);
  9. });
  10. child.on('exit', this.async());
  11. }
  12. var context = {
  13. async: function() { return loop.bind(context); }
  14. };
  15. loop.call(context);