forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually send SIGHUP to vtysh when the current session was disconnect…
…ed (sonic-net#1801) * Manually send SIGHUP to vtysh when the current session was disconnected * Address comments
- Loading branch information
1 parent
d82db79
commit bbca583
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
#!/bin/bash | ||
|
||
docker exec -i bgp vtysh "$@" | ||
# 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 "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
#!/bin/bash | ||
|
||
docker exec -i bgp vtysh "$@" | ||
# 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 "$@" | ||
fi |