diff --git a/lib/vty.c b/lib/vty.c index e70079c52d..9e0625e3cb 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2227,6 +2227,7 @@ void vty_close (struct vty *vty) { int i; + bool was_stdio; /* Cancel threads.*/ if (vty->t_read) @@ -2254,7 +2255,7 @@ vty_close (struct vty *vty) if (vty->fd > 0) close (vty->fd); else - vty_stdio_reset (); + was_stdio = true; if (vty->buf) XFREE (MTYPE_VTY, vty->buf); @@ -2267,6 +2268,9 @@ vty_close (struct vty *vty) /* OK free vty. */ XFREE (MTYPE_VTY, vty); + + if (was_stdio) + vty_stdio_reset (); } /* When time out occur output message then close connection. */