Breaking out of a Far Manager subprocess terminates entire session #8195

Closed
opened 2026-01-31 01:23:07 +00:00 by claunia · 16 comments
Owner

Originally created by @jhhcs on GitHub (May 16, 2020).

Environment

Windows build number: 10.0.18362.0
Windows Terminal version (if applicable): 0.11.1333.0 (store version)
Other software: FAR Manager (https://www.farmanager.com/)

Steps to reproduce

  • Launch FAR manager in existing shell or by creating a profile
  • run sleep 20 inside FAR (here, sleep denotes sleep.exe from Git for Windows or some other program that runs for a while and can be cancelled with a keyboard interrupt)
  • Bress Ctrl+C to break out of the sleep command

Expected behavior

The sleep command is interrupted and the FAR manager session is continued.

Actual behavior

FAR Manager is terminated.

Originally created by @jhhcs on GitHub (May 16, 2020). # Environment ```none Windows build number: 10.0.18362.0 Windows Terminal version (if applicable): 0.11.1333.0 (store version) Other software: FAR Manager (https://www.farmanager.com/) ``` # Steps to reproduce - Launch FAR manager in existing shell or by creating a profile - run `sleep 20` inside FAR (here, `sleep` denotes `sleep.exe` from Git for Windows or some other program that runs for a while and can be cancelled with a keyboard interrupt) - Bress <kbd>Ctrl</kbd>+<kbd>C</kbd> to break out of the `sleep` command # Expected behavior The `sleep` command is interrupted and the FAR manager session is continued. # Actual behavior FAR Manager is terminated.
Author
Owner

@DHowett-MSFT commented on GitHub (May 16, 2020):

Far is supposed to intercept and reject Ctrl+C keypresses using SetConsoleCtrlEvent.

  1. Which shell are you spawning it from?
  2. Is the behavior exactly the same if you use a profile whose commandline is far.exe?
@DHowett-MSFT commented on GitHub (May 16, 2020): Far is supposed to intercept and reject <kbd>Ctrl+C</kbd> keypresses using `SetConsoleCtrlEvent`. 1. Which shell are you spawning it from? 2. Is the behavior exactly the same if you use a profile whose `commandline` is `far.exe`?
Author
Owner

@jhhcs commented on GitHub (May 17, 2020):

This happens regardless of whether I launch it from cmd, PowerShell, or by using my FAR manager profile:

recording

@jhhcs commented on GitHub (May 17, 2020): This happens regardless of whether I launch it from `cmd`, PowerShell, or by using my FAR manager profile: ![recording](https://user-images.githubusercontent.com/58880204/82132696-d169db00-97e2-11ea-8fab-552ac8828c76.gif)
Author
Owner

@DHowett commented on GitHub (May 17, 2020):

I can't tell what shell that is inside far manager. CMD doesn't support sleep... so I have to presume you're using a third piece of software in there?

@DHowett commented on GitHub (May 17, 2020): I can't tell what shell that is _inside_ far manager. CMD doesn't support `sleep`... so I have to presume you're using a third piece of software in there?
Author
Owner

@jhhcs commented on GitHub (May 17, 2020):

I simply configured the prompt in FAR manager to be a simple $. It is the normal FAR manager shell.

Edit: I missed your comment about sleep and I am very sorry about the confusion, I absolutely forgot that sleep is not a built-in. I am using sleep.exe from Git for Windows, I simply used it here to have a simple program that could be Ctrl+C'd out of in a controlled manner.

@jhhcs commented on GitHub (May 17, 2020): I simply configured the prompt in FAR manager to be a simple `$`. It is the normal FAR manager shell. **Edit:** I missed your comment about `sleep` and I am very sorry about the confusion, I absolutely forgot that `sleep` is not a built-in. I am using `sleep.exe` from Git for Windows, I simply used it here to have a simple program that could be <kbd>Ctrl</kbd>+<kbd>C</kbd>'d out of in a controlled manner.
Author
Owner

@DHowett commented on GitHub (May 19, 2020):

Would you mind sharing your FAR config file? With any personal info redacted as you desire, of course. 😄

@DHowett commented on GitHub (May 19, 2020): Would you mind sharing your FAR config file? With any personal info redacted as you desire, of course. :smile:
Author
Owner

@jhhcs commented on GitHub (May 21, 2020):

To make things a little more simple, I tried this with a vanilla FAR profile (i.e. I renamed my Far Manager folder in %APPDATA% which caused FAR to create a default profile). The problem persists. However, I can share my Windows Terminal config, maybe there is something in there, although I can't see what it would be:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "copyOnSelect": false,
    "copyFormatting": false,
    "profiles":
    {
        "defaults":
        {
            "colorScheme": "red",
            "fontFace": "FixedSysEx"
        },
        "list":
        [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44be}",
                "name": "FAR Manager",
                "commandline": "far.exe",
                "hidden": false
            },
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Command Prompt",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": true,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },
    "schemes": [
        {
            "background" : "#0C0C0C",
            "foreground" : "#F2F2F2",
            "black" : "#000",
            "cursorColor": "#FFF",
            "brightBlack": "#F99",
            "brightCyan": "#4ff",
            "cyan": "#4aa",
            "brightPurple": "#f4f",
            "purple": "#a4a",
            "blue": "#222",
            "brightBlue": "#55f",
            "green" : "#13A10E",
            "brightGreen" : "#13A10E",
            "red" : "#C50F1F",
            "brightRed": "#f00",
            "white" : "#CCC",
            "brightWhite": "#EEE",
            "yellow" : "#C19C00",
            "brightYellow": "#C19C00",
            "name": "red"
        }
    ],
    "keybindings":
    [
        { "command": "paste", "keys": "ctrl+shift+v" },
        { "command": null, "keys": "alt+enter" },
        { "command": "toggleFullscreen", "keys": "alt+shift+enter" },
        { "command": null, "keys": "ctrl+," },
        { "command": null, "keys": "ctrl+." },
        { "command": null, "keys": "ctrl+shift+n" },
        { "command": "openSettings", "keys": "alt+p" },
        { "command": "find", "keys": "ctrl+shift+f" },
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}
@jhhcs commented on GitHub (May 21, 2020): To make things a little more simple, I tried this with a vanilla FAR profile (i.e. I renamed my `Far Manager` folder in `%APPDATA%` which caused FAR to create a default profile). The problem persists. However, I can share my Windows Terminal config, maybe there is something in there, although I can't see what it would be: ```json { "$schema": "https://aka.ms/terminal-profiles-schema", "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "copyOnSelect": false, "copyFormatting": false, "profiles": { "defaults": { "colorScheme": "red", "fontFace": "FixedSysEx" }, "list": [ { "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44be}", "name": "FAR Manager", "commandline": "far.exe", "hidden": false }, { "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": false }, { "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "Command Prompt", "commandline": "cmd.exe", "hidden": false }, { "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl" }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": true, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" } ] }, "schemes": [ { "background" : "#0C0C0C", "foreground" : "#F2F2F2", "black" : "#000", "cursorColor": "#FFF", "brightBlack": "#F99", "brightCyan": "#4ff", "cyan": "#4aa", "brightPurple": "#f4f", "purple": "#a4a", "blue": "#222", "brightBlue": "#55f", "green" : "#13A10E", "brightGreen" : "#13A10E", "red" : "#C50F1F", "brightRed": "#f00", "white" : "#CCC", "brightWhite": "#EEE", "yellow" : "#C19C00", "brightYellow": "#C19C00", "name": "red" } ], "keybindings": [ { "command": "paste", "keys": "ctrl+shift+v" }, { "command": null, "keys": "alt+enter" }, { "command": "toggleFullscreen", "keys": "alt+shift+enter" }, { "command": null, "keys": "ctrl+," }, { "command": null, "keys": "ctrl+." }, { "command": null, "keys": "ctrl+shift+n" }, { "command": "openSettings", "keys": "alt+p" }, { "command": "find", "keys": "ctrl+shift+f" }, { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } ] } ```
Author
Owner

@zadjii-msft commented on GitHub (Jun 9, 2020):

Hey sorry for the long silence here - we've had quite the busy month and got a little behind on triage.

Does this repro with any process at the Far prompt like that, or specifically the sleep.exe one?

How did you install Far & git for windows?

For my own future reference, 4294967295 is totally useless as an error code, ERROR_UNHANDLED_ERROR or something 😕

@zadjii-msft commented on GitHub (Jun 9, 2020): Hey sorry for the long silence here - we've had quite the busy month and got a little behind on triage. Does this repro with any process at the Far prompt like that, or specifically the `sleep.exe` one? How did you install Far & git for windows? For my own future reference, `4294967295` is totally useless as an error code, `ERROR_UNHANDLED_ERROR` or something 😕
Author
Owner

@jhhcs commented on GitHub (Jun 9, 2020):

I am in no hurry, and happy to provide any details I can. This happens with every process at the FAR prompt. Both FAR and Git for Windows were installed with the free version of Chocolatey.

@jhhcs commented on GitHub (Jun 9, 2020): I am in no hurry, and happy to provide any details I can. This happens with every process at the FAR prompt. Both FAR and Git for Windows were installed with the free version of [Chocolatey](https://chocolatey.org/).
Author
Owner

@zadjii-msft commented on GitHub (Jun 9, 2020):

Well, I'm having extreme difficulty reproing this on my end 😖

Could you do something insane to try and help narrow this down? What happens if you run a vintage console host window (like cmd.exe directly), then in that window, launch wsl, then run cmd.exe, then run far in that window and try and repro this? That'll force far to be running in a ConPTY (similar to the Terminal) but not in a Windows Terminal window. I'm trying to see if we can narrow it down to a far+conpty interaction, rather than a far+WT interaction.

@zadjii-msft commented on GitHub (Jun 9, 2020): Well, I'm having extreme difficulty reproing this on my end 😖 Could you do something _insane_ to try and help narrow this down? What happens if you run a vintage console host window (like `cmd.exe` directly), then in that window, launch `wsl`, then run `cmd.exe`, then run `far` in that window and try and repro this? That'll force `far` to be running in a ConPTY (similar to the Terminal) but not in a Windows Terminal window. I'm trying to see if we can narrow it down to a `far`+conpty interaction, rather than a `far`+WT interaction.
Author
Owner

@jhhcs commented on GitHub (Jun 10, 2020):

The bad news is: I tried what you suggested and the problem persists. The good news is:

  • I set up a fresh Windows 10 VM, updated to 1909 (18363.900),
  • installed Far Manager v3.0 build 5577 x64 (2020-03-27) via the installer from their website,
  • installed the Windows Terminal from the Microsoft store,

and could not reproduce the problem either, it all works exactly as expected. I used ping localhost for testing instead of sleep, which is built-in and also works, and ping localhost can also be used to reproduce the issue on my host computer.

TL/DR: The problem is specific to my setup, but I honestly don't know what is causing the difference as of yet. I suggest I try to find a way to reliably reproduce this. Feel free to close this out if you want to keep the queue tidy, I can create a new issue when I have figured it out and reference this one.

@jhhcs commented on GitHub (Jun 10, 2020): The bad news is: I tried what you suggested and the problem persists. The good news is: - I set up a fresh Windows 10 VM, updated to 1909 (18363.900), - installed Far Manager v3.0 build 5577 x64 (2020-03-27) via the installer from their website, - installed the Windows Terminal from the Microsoft store, and could not reproduce the problem either, it all works exactly as expected. I used `ping localhost` for testing instead of `sleep`, which is built-in and also works, and `ping localhost` can also be used to reproduce the issue on my host computer. TL/DR: The problem is specific to my setup, but I honestly don't know what is causing the difference as of yet. I suggest I try to find a way to reliably reproduce this. Feel free to close this out if you want to keep the queue tidy, I can create a new issue when I have figured it out and reference this one.
Author
Owner

@zadjii-msft commented on GitHub (Jun 10, 2020):

Heck, feel free to just post back in this thread and we can reopen if you figure anything out. Thanks!

@zadjii-msft commented on GitHub (Jun 10, 2020): Heck, feel free to just post back in this thread and we can reopen if you figure anything out. Thanks!
Author
Owner

@huettenhain commented on GitHub (Jul 17, 2021):

I still have the issue (this is @jhhcs' private account), still can't reproduce in a clean setup, just noticed that #6130 and #8942 seem related.

@huettenhain commented on GitHub (Jul 17, 2021): I still have the issue (this is @jhhcs' private account), still can't reproduce in a clean setup, just noticed that #6130 and #8942 seem related.
Author
Owner

@jhhcs commented on GitHub (Jul 23, 2021):

I am again trying to use FAR manager inside Windows Terminal, because it is becoming a very attractive alternative. This bug is the only real problem. A friend was recently able to reproduce it on their machine as well, and I am experiencing the bug both on my private machine and my work computer. The only place I cannot reproduce it is in a virtual environment. Today, I accidentally used Ctrl+C inside a FAR process inside Windows terminal and received a few additional lines of error messages that might help pin down the problem:

14:08:57.330     Main Warn QObject::~QObject: Timers cannot be stopped from another thread
14:08:57.333     Main Crit QEventDispatcherWin32::wakeUp: Failed to post a message (Invalid window handle.)

[process exited with code 4294967295]

I would like to open this again in the hope that the above error can help figure out the root cause.

@jhhcs commented on GitHub (Jul 23, 2021): I am again trying to use FAR manager inside Windows Terminal, because it is becoming a very attractive alternative. This bug is the only real problem. A friend was recently able to reproduce it on their machine as well, and I am experiencing the bug both on my private machine and my work computer. The only place I cannot reproduce it is in a virtual environment. Today, I accidentally used <kbd>Ctrl</kbd>+<kbd>C</kbd> inside a FAR process inside Windows terminal and received a few additional lines of error messages that might help pin down the problem: ``` 14:08:57.330 Main Warn QObject::~QObject: Timers cannot be stopped from another thread 14:08:57.333 Main Crit QEventDispatcherWin32::wakeUp: Failed to post a message (Invalid window handle.) [process exited with code 4294967295] ``` I would like to open this again in the hope that the above error can help figure out the root cause.
Author
Owner

@jhhcs commented on GitHub (Jul 23, 2021):

What happens if you run a vintage console host window (like cmd.exe directly), then in that window, launch wsl, then run cmd.exe, then run far in that window and try and repro this?

For some reason, I never looked into this. You are correct, the bug can be reproduced this way! In short:

  1. I ran cmd.exe
  2. Inside this terminal, I ran wsl
  3. Inside WSL, I ran cmd.exe again
  4. Inside that terminal, I ran far.exe
  5. When breaking out of a command inside this far.exe, it exited down to the terminal in step 3, i.e. the second cmd.exe.
@jhhcs commented on GitHub (Jul 23, 2021): > What happens if you run a vintage console host window (like cmd.exe directly), then in that window, launch wsl, then run cmd.exe, then run far in that window and try and repro this? For some reason, I never looked into this. You are correct, the bug **can be reproduced** this way! In short: 1. I ran `cmd.exe` 2. Inside this terminal, I ran `wsl` 3. Inside WSL, I ran `cmd.exe` again 4. Inside that terminal, I ran `far.exe` 5. When breaking out of a command inside this `far.exe`, it exited down to the terminal in step 3, i.e. the second `cmd.exe`.
Author
Owner

@jhhcs commented on GitHub (Jul 26, 2021):

Interestingly, something very similar just happened to me in a WSL terminal:

image

I mistyped ./update.sh as ./update., and the entire terminal died right after the bash error message.

@jhhcs commented on GitHub (Jul 26, 2021): Interestingly, something very similar just happened to me in a WSL terminal: ![image](https://user-images.githubusercontent.com/58880204/126980688-0453a3a6-f4e7-4364-82a7-ced63dc5ad43.png) I mistyped `./update.sh` as `./update.`, and the entire terminal died right after the bash error message.
Author
Owner

@huettenhain commented on GitHub (Sep 4, 2021):

I think I discovered a solution for this problem after a discussion in FarGroup/FarManager#442

To summarize: I have installed FAR using chocolatey, and chocolatey installs a command-line shim executable. It is only this shim executable that seems to incorrectly handle Ctrl-C.

@huettenhain commented on GitHub (Sep 4, 2021): I think I discovered a solution for this problem after a discussion in FarGroup/FarManager#442 To summarize: I have installed FAR using chocolatey, and chocolatey installs a command-line shim executable. It is only _this shim executable_ that seems to incorrectly handle <kbd>Ctrl</kbd>-<kbd>C</kbd>.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8195