Closed fool-derek closed 5 years ago
SIGSTOP and SIGCONT are signals that can't be caught, i.e., Node.js has no control over them and cannot influence their actions. In other words, this is not a Node.js bug.
This issue should be moved to nodejs/help by an admin, this bug tracker is not the right place for it.
$ cat 1721.js
const child_process = require('child_process')
if (process.argv[2] === 'child') {
setInterval(() => {
console.log(process.hrtime()[0])
}, 1000)
} else {
const cp = child_process.spawn(process.execPath, [__filename, 'child'])
cp.stdout.on('data', (d) => {
console.log(d.toString())
})
setTimeout(() => {
cp.kill('SIGSTOP')
setTimeout(() => {
cp.kill('SIGCONT')
}, 5000)
}, 5000)
}
$ strace -f ./node 1721 2> 1
3714487
3714488
3714489
3714490
3714496
3714497
3714498
$ grep "SIGSTOP" 1
[pid 108894] kill(108901, SIGSTOP) = 0
[pid 108901] --- SIGSTOP {si_signo=SIGSTOP, si_code=SI_USER, si_pid=108894, si_uid=50141} ---
[pid 108901] --- stopped by SIGSTOP ---
[pid 108907] --- stopped by SIGSTOP ---
[pid 108906] --- stopped by SIGSTOP ---
[pid 108905] --- stopped by SIGSTOP ---
[pid 108904] --- stopped by SIGSTOP ---
[pid 108903] --- stopped by SIGSTOP ---
[pid 108902] --- stopped by SIGSTOP ---
[pid 108894] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_STOPPED, si_pid=108901, si_uid=50141, si_status=SIGSTOP, si_utime=7, si_stime=1} ---
$ grep "SIGCONT" 1
rt_sigaction(SIGCONT, {SIG_DFL, [], SA_RESTORER, 0x7ff39a2815d0}, NULL, 8) = 0
[pid 108901] rt_sigaction(SIGCONT, {SIG_DFL, [CONT], SA_RESTORER|SA_RESTART, 0x7ff399edb280}, {SIG_DFL, [], SA_RESTORER, 0x7ff39a2815d0}, 8) = 0
[pid 108901] rt_sigaction(SIGCONT, {SIG_DFL, [], SA_RESTORER, 0x7f833604c5d0}, NULL, 8) = 0
[pid 108894] kill(108901, SIGCONT) = 0
[pid 108894] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_CONTINUED, si_pid=108901, si_uid=50141, si_status=SIGCONT, si_utime=7, si_stime=1} ---
[pid 108901] --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=108894, si_uid=50141} ---
So for me everything falls in place. You may use this code and method to see what happens in the problematic system. Hope this helps.
ping @DerekChenGit
asnwered, closing
I am writing a Node.js application, in the code of this application, the parent process spawn a node.js subprocess. Firstly, the parent process send "SIGSTOP" to the subprocess, then send "SIGCONT" to wake this subprocess, but it doesn't work in Ubuntu on VirtualBox, but in other environments (such as Debian on VirtualBox, Ubuntu on real machine), this code can works, it is very strange! Anyone can help me answer this question?
I have try to set the subprocess priority to -10 using "nice" command, the "SIGCONT" signal can works, maybe this problem is caused by the CPU scheduling.