summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-11-21 21:51:23 +0700
committerlaforge <laforge@osmocom.org>2019-11-30 18:49:33 +0000
commit7a35b78648a3a0761cbb0263b2d75bb5a6f2a3a2 (patch)
treedb78b630fb74deffb91f91537265c99d381bf704 /src
parent54df08e3fac62ce99c39e71c47c9701e02b40317 (diff)
libosmovty: simplify condition checking vty->fd in vty_close()
On POSIX systems, standard I/O streams - stdin, stdout, and stderr, always have default file descriptors 0, 1, and 2 respectively. Change-Id: Ied35d142af0ba0f5ad78975b8f22c35b32d6ff71
Diffstat (limited to 'src')
-rw-r--r--src/vty/vty.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 8cc2a3ae..ebdf9fc9 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -231,8 +231,8 @@ void vty_close(struct vty *vty)
/* Unset vector. */
vector_unset(vtyvec, vty->fd);
- /* Close socket. */
- if (vty->fd > 0 && vty->fd != fileno(stderr)) {
+ /* Close socket (ignore standard I/O streams). */
+ if (vty->fd > 2) {
close(vty->fd);
vty->fd = -1;
}