question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not wait for child process termination when using node's "--inspect" option

See original GitHub issue
  • nodemon -v: 2.0.7
  • node -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);

image

It works fine when the “–inspect” option is not used image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Wesitoscommented, Jul 15, 2021

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 :v

0reactions
github-actions[bot]commented, Jul 28, 2022

Automatically closing this issue due to lack of activity

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found