Describe the bug
I use Create React App as part of an asset pipeline in a web framework (in my case Phoenix). As part of the development pipeline, I've set up a watcher to run react-scripts start whenever my web server starts.
This works fine, but whenever I terminate my web server, Webpack dev server remains running in the background. I want Webpack dev server to listen on stdin for SIGINT and SIGTERM so it can terminate itself.
I noticed in start.js that there is an event listener set up for SIGINT and SIGTERM, but this didn't work for me.
Referring to this documentation, I can fix the issue on my machine by adding this line;
before any of the process event handlers are added. I think process will exit prematurely and not listen to stdin without that.
If this works for everyone, I'd be happy to put in a PR.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
Start, listen, stdin, sigint, and sigterm.
Environment
System:
OS: macOS 10.15.7
CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
Binaries:
Node: 15.8.0 - ~/.asdf/installs/nodejs/15.8.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 7.5.4 - ~/.asdf/installs/nodejs/15.8.0/.npm/bin/npm
Browsers:
Chrome: 92.0.4515.107
Edge: Not Found
Firefox: 83.0
Safari: 14.1.1
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Described above.
Expected behavior
react-scripts start should listen to stdin for SIGINT and SIGTERM and terminate itself.
Actual behavior
Webpack dev server keeps running in the background after its spawning process gets terminated.

Describe the bug
I use Create React App as part of an asset pipeline in a web framework (in my case Phoenix). As part of the development pipeline, I've set up a watcher to run
react-scripts startwhenever my web server starts.This works fine, but whenever I terminate my web server, Webpack dev server remains running in the background. I want Webpack dev server to listen on stdin for SIGINT and SIGTERM so it can terminate itself.
I noticed in start.js that there is an event listener set up for SIGINT and SIGTERM, but this didn't work for me.
Referring to this documentation, I can fix the issue on my machine by adding this line;
before any of the process event handlers are added. I think process will exit prematurely and not listen to stdin without that.
If this works for everyone, I'd be happy to put in a PR.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
Start, listen, stdin, sigint, and sigterm.
Environment
Steps to reproduce
Described above.
Expected behavior
react-scripts startshould listen to stdin for SIGINT and SIGTERM and terminate itself.Actual behavior
Webpack dev server keeps running in the background after its spawning process gets terminated.