Tab doesn't close after exiting Cygwin Bash
Versions
ConEmu build: 210912 x64 OS version: Windows 10 Pro x64 Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): cygwin bash
Problem description
After exiting bash (using Ctrl+D or exit command) the tab never closes. The word "exit" printed by bash on exit is visible, the caret keeps blinking on the next line. A middle-click on the tab closes it without showing any confirmation dialog.
Steps to reproduce
- Install Cygwin
- Create Bash task Name: Bash Parameters: /dir "%CD%" Task: %ConEmuDrive%\cygwin\bin\conemu-cyg-64.exe bash.exe -new_console:n:C:"%ConEmuDrive%\cygwin\Cygwin.ico":m:/mnt
- Run Bash
- Exit with Ctrl+D or by executing
exit
Actual results
Bash exits, but the tab stays open
Expected results
Tab should close
If the tab does not close, that means it has running processes. Check them here: https://conemu.github.io/en/SettingsInfo.html
And I guess you run bash without connector: https://conemu.github.io/en/CygwinMsysConnector.html
I will check later today regarding the processes. I am using the connector (conemu-cyg-64.exe), you can see it in my Task, mentioned in step 2 of steps to reproduce
Screenshots of the Setting dialog and ConEmu window might help.
So the culprit is ssh-pageant
I'm running it from my bash profile file, as recommended in it's README:
Edit your ~/.bashrc (or ~/.bash_profile) to add the following: eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
The -r option means reuse, so that only one ssh-pageant daemon is running at a time. So if I open several tabs with bash, all of them except the first one will be closable normally (the tab will close). The first tab has the ssh-pageant daemon running, and I guess it's attached to the console. Is there a way to run it detached from the console? Or perhaps I should set it up to run on user login via Task Scheduler or some other mechanism. Suggestions?
Screenshots:

I've solved the problem. Using the Local Group Policy Editor, I have created a Logon script (actually, quite a while ago). Script name: C:\cygwin\bin\run.exe Script parameters: cmd.exe /c C:\usr\etc\rc.d\logon.cmd
logon.cmd:
@echo off
set Path=C:\cygwin\bin:%Path%
bash /etc/init.d/local start
The local script is omitted as it's not really important, it just runs multiple sub-scripts located in /etc/local.d, the relevant one for ssh-pageant is:
#!/bin/sh
SSH_AUTH_SOCK="/home/$USERNAME/.ssh-pageant-auth-sock"
setx SSH_AUTH_SOCK "${SSH_AUTH_SOCK}"
setsid /usr/bin/ssh-pageant -r -a "${SSH_AUTH_SOCK}" &>/dev/null
This way, ssh-pageant is started at user logon, and when I run Far or bash in ConEmu, they already have the correct SSH_AUTH_SOCK variable, and everything works great. My ssh keys are stored in a KeePassXC database, KeePassXC adds them to Pageant, when I unlock the database, and ssh-pageant allows Cygwin programs (git, ssh) to use those keys transparently.
I've removed eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME") from my bash_profile as it's not needed anymore.
I guess this issue can be closed?