Skip to content
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

Ctrl+C on cargo run #806

Closed
alexreg opened this issue Nov 11, 2016 · 12 comments · Fixed by #1242 or #2014
Closed

Ctrl+C on cargo run #806

alexreg opened this issue Nov 11, 2016 · 12 comments · Fixed by #1242 or #2014
Labels

Comments

@alexreg
Copy link

alexreg commented Nov 11, 2016

When I Ctrl+C on cargo run and my Rust program is set up to intercept the signal, the Rustup process stops and returns control to the terminal, even though my Rust program (and indeed Cargo) may still be running. I've observed this on the latest version of Rustup.

I think it would be best for Rustup to do something similar to what cargo run does, and intercept Ctrl+C when running a program, and ignore it – instead, it should just check regularly to see if the program (cargo) has exited.

Note: this is confirmed not to be a cargo issue, as per rust-lang/cargo#3281.

@KalitaAlexey
Copy link

What is the status of the issue?

@KalitaAlexey
Copy link

What is the status of the issue?
Is it still relevant?
I can work on it if it is relevant.

@alexreg
Copy link
Author

alexreg commented Feb 26, 2017 via email

@KalitaAlexey
Copy link

I am working on it.

@brson
Copy link
Contributor

brson commented Mar 17, 2017

I'd like to solve this and #845 without giving up fork/exec. A strategy along the lines @alexreg describes in the op seems workable.

@brson
Copy link
Contributor

brson commented Mar 17, 2017

Some rationale here: #972 (comment)

alexcrichton added a commit to alexcrichton/rustup.rs that referenced this issue Aug 22, 2017
This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes rust-lang#806
alexcrichton added a commit to alexcrichton/rustup.rs that referenced this issue Aug 22, 2017
This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes rust-lang#31
Closes rust-lang#806
bors added a commit that referenced this issue Aug 22, 2017
Use `exec` on Unix to propagate signals

This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes #31
Closes #806
alexcrichton added a commit to alexcrichton/rustup.rs that referenced this issue Aug 22, 2017
This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes rust-lang#31
Closes rust-lang#806
bors added a commit that referenced this issue Aug 22, 2017
Use `exec` on Unix to propagate signals

This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes #31
Closes #806
mattico pushed a commit to mattico/rustup.rs that referenced this issue Apr 5, 2018
This is only possible when telemetry is disabled, but almost all of the time it
is! This should help fix lots of common rustup-related issues related to signals
and such.

Closes rust-lang#31
Closes rust-lang#806
@Vlad-Shcherbina
Copy link

This still happens on Windows.

Steps to reproduce

  1. Create the following program:
    // [dependencies]
    // ctrlc = "*"
    fn main() {
        ctrlc::set_handler(move || {
            println!("Ctrl-C received, but I'm not exiting.");
        });
        loop {}
    }
  2. cargo run (where cargo is rustup)
  3. Press Ctrl-C.

Expected result

The program should print Ctrl-C received, but I'm not exiting. and continue running.

Actual result

The program terminates.

Version info

> rustup --version
rustup 1.18.3 (435397f48 2019-05-22)

I tried it without (C:\Users\username\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo.exe run). It works as expected.

Cargo itself used to have this problem before (rust-lang/cargo#4575), but it was solved with this workaround: rust-lang/cargo#6004.

@kinnison
Copy link
Contributor

@alexcrichton Do you have any idea of the complexity of resolving this for rustup?

@kinnison kinnison reopened this Sep 23, 2019
@alexcrichton
Copy link
Member

The Cargo solution looked like rust-lang/cargo#6004 for Windows, so based on that I'd guess it'd have a relatively small impact?

@kinnison
Copy link
Contributor

Assuming #2014 builds OK, could @Vlad-Shcherbina or @alexreg please go to the PR, go through to the appveyor build, find the artifact, download a test copy of rustup install it and give it a go?

@kinnison
Copy link
Contributor

My apologies, it looks like the artifacts don't get collected, so you'll need to build a copy locally.

@Vlad-Shcherbina
Copy link

In the scenario I described, #2014 appears to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants