diff options
author | Helmut Schaa <helmut.schaa@googlemail.com> | 2013-09-17 08:48:48 +0200 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2013-09-17 21:30:09 +0200 |
commit | f51f9cc5738d340423e44e678829402b367cf866 (patch) | |
tree | f549312af39e931c54c6a0a1073b38c3119567c2 | |
parent | b803c65259b426a2b2ba14d342bec4de598734b8 (diff) | |
download | unitd-f51f9cc5738d340423e44e678829402b367cf866.tar unitd-f51f9cc5738d340423e44e678829402b367cf866.zip |
procd: Exit askfirst on read error
When running askfirst on an unused tty device askfirst starts
busylooping forever. Fix this by returning an error if we read
an EOF.
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
-rw-r--r-- | askfirst.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -42,12 +42,19 @@ static int redirect_output(const char *dev) int main(int argc, char **argv) { + int c; + if (redirect_output(argv[1])) fprintf(stderr, "%s: Failed to open %s\n", argv[0], argv[1]); printf("Please press Enter to activate this console.\n"); - while (getchar() != 0xA) - ; + do { + c = getchar(); + if (c == EOF) + return -1; + } + while (c != 0xA); + execvp(argv[2], &argv[2]); printf("%s: Failed to execute %s\n", argv[0], argv[2]); |