microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.65k stars 29.04k forks source link

ctr+c isn't working in command prompt opend in VSCode #7740

Closed NCC1701M closed 8 years ago

NCC1701M commented 8 years ago

Steps to Reproduce:

  1. Open a folder in VSCode e.g. the "Angular quickstart project"
  2. Use ctrl+shift+c to open folder in command prompt
  3. Execute a console program (e.g. in the Angular project run "npm start")
  4. Wait until program runs
  5. Use ctrl+c to stop running program

When you try to stop the running program with ctrl+c it isn't working. Tried it with the command mentioned above and also with "cordova run browser".

When you start a command prompt at the normal way it is working.

Tyriar commented 8 years ago

@NCC1701M does the command not stop on the integrated terminal or the external (system) terminal?

NCC1701M commented 8 years ago

On the external (system) terminal.

Tyriar commented 8 years ago

Is this cmd.exe? VS Code should not have any effect on the external terminal, any other details? A screenshot might be helpful.

NCC1701M commented 8 years ago

Yes, it's cmd.exe. Well it sometimes work and sometimes not but when it doesn't work it's always started via ctrl+shift+c from VSCode. Is there a special way VSCode starts cmd.exe?

I can post you a screenshot but you won't see when I hit ctrl+c

Tyriar commented 8 years ago

cmd.exe is spawned with the following code:

    private spawnTerminal(spawner, configuration: ITerminalConfiguration, command: string, path?: string): TPromise<void> {
        let terminalConfig = configuration.terminal.external;
        let exec = terminalConfig.windowsExec || DEFAULT_TERMINAL_WINDOWS;
        // The '""' argument is the window title. Without this, exec doesn't work when the path
        // contains spaces
        let cmdArgs = ['/c', 'start', '/wait', '""', exec];

        return new TPromise<void>((c, e) => {
            let env = path ? { cwd: path } : void 0;
            let child = spawner.spawn(command, cmdArgs, env);
            child.on('error', e);
            child.on('exit', () => c(null));
        });
    }

Where command is %COMSPEC% if it's defined, otherwise cmd.exe. So this is the command that would be used:

%COMSPEC% /c start /wait "" cmd

You could try using the 64-bit cmd and see if that fixes your problem:

"terminal.external.windowsExec": "C:\Windows\SysWOW64\cmd.exe"
Tyriar commented 8 years ago

@NCC1701M you still having issues with this?

NCC1701M commented 8 years ago

@Tyriar No I don't have the problem at the moment. I'd like to say it could be a OS problem but I had the issue on different machines with different OSs (Win 10 and Win 7) and only when I run it via CTRL+SHIFT+C from VSCode. But it is working at the moment. So I thing you can close this issue.

Tyriar commented 8 years ago

Thanks for the update :smiley: