| From da1ad19f039c303808d36d1cf318cfd44aae77a4 Mon Sep 17 00:00:00 2001 |
| From: Joseph Hwang <josephsih@chromium.org> |
| Date: Wed, 30 Nov 2011 14:59:37 +0800 |
| Subject: [PATCH] 1.0.5-timeout |
| |
| The second argument of evemu-record is used as a timeout value. |
| The default timeout value for evemu-record is 10 seconds if no value |
| is specified. If the timeout value is set to -1, evemu-record would |
| not terminate until it receives the SIGINT or SIGTERM signal. |
| --- |
| tools/evemu-record.c | 12 +++++++++--- |
| 1 files changed, 9 insertions(+), 3 deletions(-) |
| |
| diff --git a/tools/evemu-record.c b/tools/evemu-record.c |
| index f75c0bb..4d29e7f 100644 |
| --- a/tools/evemu-record.c |
| +++ b/tools/evemu-record.c |
| @@ -60,10 +60,16 @@ void close_file() |
| |
| int main(int argc, char *argv[]) |
| { |
| + int timeout; |
| + char *endp; |
| + |
| signal(SIGINT, close_file); |
| signal(SIGTERM, close_file); |
| - if (argc < 2) { |
| - fprintf(stderr, "Usage: %s <device>\n", argv[0]); |
| + |
| + timeout = argc == 3 ? strtol(argv[2], &endp, 10) : WAIT_MS; |
| + if (argc < 2 || argc > 3 || (argc == 3 && *endp != '\0')) { |
| + fprintf(stderr, "Usage: %s <device> [timeout_in_ms]\n", |
| + argv[0]); |
| return -1; |
| } |
| fd = open(argv[1], O_RDONLY | O_NONBLOCK); |
| @@ -71,7 +77,7 @@ int main(int argc, char *argv[]) |
| fprintf(stderr, "error: could not open device\n"); |
| return -1; |
| } |
| - if (evemu_record(stdout, fd, WAIT_MS)) { |
| + if (evemu_record(stdout, fd, timeout)) { |
| fprintf(stderr, "error: could not describe device\n"); |
| } |
| close(fd); |
| -- |
| 1.7.7.3 |
| |