diff options
author | Vladislav Grishenko <themiron@yandex-team.ru> | 2021-03-15 02:48:09 +0500 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2024-03-05 18:51:37 +0000 |
commit | 29e916a07c31d63ed6935354b99f16743842fdc6 (patch) | |
tree | 0727b3eb98f753677824b63e05d18063f8323b36 /src | |
parent | 09c6cae8c819b71f32fa4d657756c063d4549366 (diff) |
vpp: fix stdin vs non-interactive command clash
In case of both stdin and non-interactive inputs are there
vppctl parses them all, causing mixed corrupted output:
$ echo foo | vppctl sh bar
show: unknown input `bar'
unknown input `foo'
This is not desired, stdin should be ignored if there's a command
but still allow stdin commands - following cases are still equal:
$ vppctl foo
$ echo foo | vppctl
Type: fix
Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Change-Id: I98667391627150c98a57d49ae544e48ef3351f34
Diffstat (limited to 'src')
-rw-r--r-- | src/vpp/app/vppctl.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/vpp/app/vppctl.c b/src/vpp/app/vppctl.c index 7166ce13689..5b93cec8229 100644 --- a/src/vpp/app/vppctl.c +++ b/src/vpp/app/vppctl.c @@ -291,17 +291,20 @@ main (int argc, char *argv[]) efd = epoll_create1 (0); /* register STDIN */ - event.events = EPOLLIN | EPOLLPRI | EPOLLERR; - event.data.fd = STDIN_FILENO; - if (epoll_ctl (efd, EPOLL_CTL_ADD, STDIN_FILENO, &event) != 0) + if (cmd == 0) { - /* ignore EPERM; it means stdin is something like /dev/null */ - if (errno != EPERM) + event.events = EPOLLIN | EPOLLPRI | EPOLLERR; + event.data.fd = STDIN_FILENO; + if (epoll_ctl (efd, EPOLL_CTL_ADD, STDIN_FILENO, &event) != 0) { - error = errno; - fprintf (stderr, "epoll_ctl[%d]", STDIN_FILENO); - perror (0); - goto done; + /* ignore EPERM; it means stdin is something like /dev/null */ + if (errno != EPERM) + { + error = errno; + fprintf (stderr, "epoll_ctl[%d]", STDIN_FILENO); + perror (0); + goto done; + } } } @@ -341,7 +344,7 @@ main (int argc, char *argv[]) if (n == 0) continue; - if (event.data.fd == STDIN_FILENO) + if (event.data.fd == STDIN_FILENO && cmd == 0) { int n; char c[100]; |