joyent/node — pull request #3437 by migounette (2012-06-14 12:37:16+00:00)
Title: Add SIGUSR1 support for Windows in order to invoke the debugger at Runtime

Add the SIGUSR1 supports by mapping SIGUSR1 on SIGBREAK. It permits to invoke the debugger at runtime like this:

=========== SAMPLE CODE ========

function waitms(msToWait)
{
var date = new Date();
var curDate = null;

do {
curDate = new Date();
debugger;
}
while(curDate-date < msToWait);
}

function processScript() {
console.log('hello world');
}

try {
process.kill(process.pid, 'SIGUSR1');

// Now it's time to set a breakpoint
process.nextTick(function () {
waitms(5000);
processScript();
});

}
catch(err) {
console.log('Error : ' + err);
}