diff options
Diffstat (limited to 'rpt.c')
-rw-r--r-- | rpt.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include <errno.h> #include <fcntl.h> #include <getopt.h> +#include <poll.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> @@ -225,7 +226,18 @@ main(int argc, char* argv[]) return 3; } - copy_stdin(); + struct pollfd pollfd = {.fd=STDIN_FILENO, .events=POLLIN, .revents=0}; + + if (poll(&pollfd, 1, 0) < 0) + { + fclose(stdin_clone); + perror("poll"); + return 4; + } + + if (pollfd.revents & POLLIN) + copy_stdin(); + repeat_cmd(argv + optind, count, handle_error_f); fclose(stdin_clone); |