Bash and exit behavior

Hi all,

I tried to move from ash to bash shell however I’m experiencing the following behavior of exit.

In ash (works as I expect it):

  1. Login to Omnia over ssh (from putty)
  2. Connect to container - lxc-attach -n
  3. Work in container
  4. When I type ‘exit’ then I exit the container and I’m back in Omnia’s ash shell

In bash:
1 - 3. the same as above
4. When I type ‘exit’ then the whole putty session closes - so I do not end up in bash.

Similarly if I go bash->screen->lxc-attach and type exit then also screen exits and I end up in bash. when I run ash->screen->lxc-attach and type exit then I stay in screen.

Any idea on what drives the behavior of bash?

Thanks.
Radek

Hi Radek,
I think this link could help you to solve your problem.

I found it yesterday when I was looking into it - Ctrl-a +q works for lxc-console however it doesn’t for lxc-attach. Advantage of lxc-attach is that you don’t need to login into container.

I am using screen to work with containers… (inspired by this http://pastebin.com/mjXLdxQs ) one window per each container/shell i need

startup_message off
defshell -bash
defutf8 on
defbce on
nonblock on
nethack on

screen -t __NODE__ 0
screen -t _IRC-UX_ 1
screen -t _KRYTEN_ 2
screen -t __ABLE__ 3
screen -t _HUDZEN_ 4
select 1

altscreen on

term screen-256color

bindkey -k k7 prev
bindkey -k k8 next
bindkey -k k9 detach

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'

And you can tune-up keybindings to perform several actions, prepare some host/guest aliases (and profile variables) to not exit when you type exit or pres ctrl+d.

alias goAble='lxc-attach -n ${ABLE}'
alias goHudzen='lxc-attach -n ${HUDZEN}'
alias goKryten='lxc-attach -n ${KRYTEN}'

… and for sure lxc-attach and lxc-console are not same comands to get you tty/shell, so in fact exit/ctrl+d behavior is quite expectable when using lxc-attach. It is better to use console comand and normally login using containers’ own users/passwords …

and ideal solution is to setup sshd inside the lxc container and later connect via ssh not via lxc-* comands :slight_smile: