Created
April 8, 2014 18:14
-
-
Save ETiV/10165657 to your computer and use it in GitHub Desktop.
测试 NodeJS 支持的 kill signals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by ETiV on 4/9/14. | |
*/ | |
var target_pid = 26263; | |
var signals = ['SIGHUP', | |
'SIGINT', | |
'SIGQUIT', | |
'SIGILL', | |
'SIGTRAP', | |
'SIGABRT', | |
'SIGIOT', | |
'SIGBUS', | |
'SIGFPE', | |
// 'SIGKILL', // will raise error | |
// 'SIGUSR1', // will start debugger | |
'SIGSEGV', | |
'SIGUSR2', | |
'SIGPIPE', | |
'SIGALRM', | |
'SIGTERM', | |
'SIGCHLD', | |
'SIGCONT', | |
//'SIGSTOP', // will raise error | |
'SIGTSTP', | |
'SIGTTIN', | |
'SIGTTOU', | |
'SIGURG', | |
'SIGXCPU', | |
'SIGXFSZ', | |
'SIGVTALRM', | |
'SIGPROF', | |
'SIGWINCH', | |
'SIGIO', | |
'SIGSYS']; | |
for (var i = 0; i < signals.length; i++) { | |
process.kill(target_pid, signals[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by ETiV on 4/9/14. | |
*/ | |
console.log(process.pid); | |
var signals = ['SIGHUP', | |
'SIGINT', | |
'SIGQUIT', | |
'SIGILL', | |
'SIGTRAP', | |
'SIGABRT', | |
'SIGIOT', | |
'SIGBUS', | |
'SIGFPE', | |
// 'SIGKILL', // will raise error | |
// 'SIGUSR1', // will start debugger | |
'SIGSEGV', | |
'SIGUSR2', | |
'SIGPIPE', | |
'SIGALRM', | |
'SIGTERM', | |
'SIGCHLD', | |
'SIGCONT', | |
//'SIGSTOP', // will raise error | |
'SIGTSTP', | |
'SIGTTIN', | |
'SIGTTOU', | |
'SIGURG', | |
'SIGXCPU', | |
'SIGXFSZ', | |
'SIGVTALRM', | |
'SIGPROF', | |
'SIGWINCH', | |
'SIGIO', | |
'SIGSYS']; | |
for (var i = 0; i < signals.length; i++) { | |
console.log('install:', signals[i]); | |
try { | |
process.on(signals[i], (function () { | |
console.log('Got signal:', this.sig); | |
}).bind({sig: signals[i]})); | |
} catch (e) { | |
console.log(e); | |
} | |
} | |
process.stdin.resume(); // Start reading from stdin so we don't exit. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
测试结果: