When a session closes, JuiceSSH checks the exit code (also known as exit status) of the remote shell.


If the exit code is non-zero, then JuiceSSH assumes that the connection was closed unexpectedly or failed somehow.

It will display a failed connection notification in the android notification area, allowing you to easily reconnect or view/save the session transcript.


If the exit code is 0, then JuiceSSH assumes the session was successful, and doesn't display a connection failed notification.


When you use the 'exit' command to close a bash shell, it sets the shell exit code to be that of the last command run.

By default, running 'exit' is the same as running 'exit $?' 

This means that if the last command you ran before typing exit was not successful, the non-zero exit code will be passed back to JuiceSSH.


For example:

   

# This will cause a failed connection notification as the previous command failed:

$ ping www.non-existant-host.com

ping: unknown www.non-existant-host.com

$ exit


# This will not cause a failed connection notification :

$ echo "hello"

hello

$ exit


# You can override the value that is passed back to JuiceSSH from your shell, by specifying it manually. This will not cause a failed connection notification:

$ ping www.non-existant-host.com

ping: unknown www.non-existant-host.com

$ exit 0 


This is the standard behaviour of most shells, including Bash.

http://www.tldp.org/LDP/abs/html/exit-status.html