Mohammedz.com

For Linux and Shell scripting.

Session hangs when exiting ssh

Leave a comment


OpenSSH may hang when exiting. This can occur when there is an active background process. The problem can be verified by executing the following command:

$ sleep 20 & exit

Try to use this instead:

$ sleep 20 < /dev/null > /dev/null 2>&1 &

A work around for bash users is to place “shopt -s huponexit” in
either /etc/bashrc or ~/.bashrc. Otherwise, consult your shell’s man page for an option to enable it to send a HUP signal to active jobs when exiting.

~mohammed

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s