Does not wait for child process termination when using node's "--inspect" option
See original GitHub issuenodemon -v
: 2.0.7node -v
: 14.17.2- Operating system/terminal environment: Ubuntu
- Command you ran:
nodemon --inspect=9223 index.js
Expected behaviour
Nodemon should wait for the child process termination before starting a new process.
Actual behaviour
When using node’s “–inspect” option, Nodemon does not wait for the process termination before starting a new process.
Steps to reproduce
Run nodemon --inspect index.js
and trigger a restart
Contents of index.js
console.log('Started:', process.pid);
process.on('SIGUSR2', () => {
// Delay process termination
setTimeout(() => {
console.log('Shutting down:', process.pid);
process.exit(0);
}, 100);
});
// This is only to keep the process alive
setTimeout(() => {}, 100000);
It works fine when the “–inspect” option is not used
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Node.js Child Processes: Everything you need to know
There are four different ways to create a child process in Node: spawn() , fork() , exec() , and execFile() . We're going...
Read more >How to wait for exit of non-children processes - Stack Overflow
The usual practice is to poll using kill(pid, 0) and looking for return value -1 and errno of ESRCH to indicate that the...
Read more >Exit status of a child process in Linux - GeeksforGeeks
Note: By default, waitpid() waits only for terminated children, but this behavior is modifiable via the options argument such as WIFEXITED, ...
Read more >waitpid() — Wait for a specific child process to end - IBM
Suspends the calling process until a child process ends or is stopped. More precisely, waitpid() suspends the calling process until the system gets...
Read more >Child process | Node.js v19.3.0 Documentation
If the subprocess writes to stdout in excess of that limit without the output being captured, the subprocess blocks waiting for the pipe...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it’s because sh does not propagates signals to a blocking child processes (https://unix.stackexchange.com/a/196053) at least in linux, I have no way of testing this on macos. And the way nodemon runs a process (using “spawn”) outside windows is running
sh -c
. I think this could be fixed by spawning the child process in a bit more complex sh script (with proper signal handling). Maybe calling exec is enough :vAutomatically closing this issue due to lack of activity