-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With cargo run, forward termination signal to child process on Windows #4575
Comments
On unix-like systems, |
Windows 8.1 |
I don't personally know how to "forward signals" on Windows, but an implementation would be most welcome! |
Cargo uses job objects when running any child processes, so when cargo exits all child processes are automatically and forcefully terminated. In order to be able to have your program respond to console control events when using I've seen enough people run into this roadblock that maybe we should reconsider why we're using job objects and try to solve the original problem some other way. |
I believe the original issue was that when cargo received |
I'm using |
The Ctrl-C handler won't get triggered with |
My above change, #6004 fixes this for cmd.exe shells, but it's still a problem for PowerShell (maybe I'll try to poke at that at some point?) and likely MSYS shells. |
@zachlute Thanks! So with your fix, a handler registered with the |
Yes, though there's also a caveat. This fixes it for raw cargo.exe runs, but my understanding is that when run through rustup it's probably still an issue because I'll have to make the same fix in rustup. Now that this has landed, I'll try to poke at that once it hits nightly and see what's up. |
@zachlute I usually run it through |
@zachlute what is the state of this, can this be closed now? |
My understanding of the status quo here is that this problem is, as mentioned above, fixed for cmd.exe shells (and likely PowerShells?), but not for MSYS shells, because as @alexcrichton mentions in #6004, those don't send Ctrl+C events and just get killed with So uh...I think my answer is 'yes, this is fixed for most people'. |
Ok I will close this for not, we can reopen if someone is having problems. |
I'm using the ctrlc crate to catch Ctrl-C in my program but it doesn't work when it's started by
cargo run
, which defeats the purpose because I don't need to handle Ctrl-C in the release version, only during development.Would it be possible for
cargo run
to also use the ctrlc crate and forward the termination signal to the child process?The text was updated successfully, but these errors were encountered: