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

function respawn () {
  var child = exec('date', function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) console.log('exec error: ' + error);
  });

  child.on('exit', function (code, signal) {
    console.log('exit code: ', code);
    console.log('exit signal: ', signal);
    console.warn('\nCNTL-C to exit.\n');
    child = respawn(); 
  });
}

respawn();


// Note: You'll probably want to be a bit more discerning about the respawn 
based on the exit code or the signal.
// gist: http://dshaw.me/GFHhTL
//
// Daniel Shaw
// @dshaw

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to