Manually send SIGHUP to vtysh when the current session was disconnected (#1801)

* Manually send SIGHUP to vtysh when the current session was disconnected

* Address comments
This commit is contained in:
pavel-shirshov 2018-06-20 12:15:09 -07:00 committed by GitHub
parent d82db79051
commit bbca58329b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,16 @@
#!/bin/bash #!/bin/bash
# Determine whether stdout is on a terminal
if [ -t 1 ] ; then
# Prepare a function to send HUP signal to vtysh in the container
# we mark the new instance of vtysh with the current tty as a tag
TTY=$(tty)
function cleanup
{
docker exec -i bgp pkill -HUP -f "vtysh $TTY"
}
trap cleanup HUP
docker exec -ti bgp vtysh "$TTY" "$@"
else
docker exec -i bgp vtysh "$@" docker exec -i bgp vtysh "$@"
fi

View File

@ -1,3 +1,16 @@
#!/bin/bash #!/bin/bash
# Determine whether stdout is on a terminal
if [ -t 1 ] ; then
# Prepare a function to send HUP signal to vtysh in the container
# we mark the new instance of vtysh with the current tty as a tag
TTY=$(tty)
function cleanup
{
docker exec -i bgp pkill -HUP -f "vtysh $TTY"
}
trap cleanup HUP
docker exec -ti bgp vtysh "$TTY" "$@"
else
docker exec -i bgp vtysh "$@" docker exec -i bgp vtysh "$@"
fi