Skip to content

Commit 60ac7d8

Browse files
committed
support slect timeout
1 parent 004a58e commit 60ac7d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tapdev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <linux/if_tun.h>
2020
#include <linux/if_ether.h>
2121

22+
#include <time.h>
23+
2224
#define BUF_MAX_ASCII 16000
2325
#define BUF_MAX 9400
2426

@@ -149,6 +151,7 @@ int main(int argc, char **argv)
149151
struct ifreq ifr;
150152
struct in6_rtmsg rt;
151153
struct stat st;
154+
struct timeval timeout = { 5, 0 };
152155

153156
if (argc < 2) {
154157
fprintf(stderr, "Usage:%s {devicename}\n", argv[0]);
@@ -223,7 +226,7 @@ int main(int argc, char **argv)
223226
FD_SET(txpipe_fd, &fdset);
224227
FD_SET(tap_fd, &fdset);
225228

226-
ret = select(maxfd + 1, &fdset, NULL, NULL, NULL);
229+
ret = select(maxfd + 1, &fdset, NULL, NULL, &timeout);
227230
if (ret < 0) {
228231
perror("select");
229232
return 1;

0 commit comments

Comments
 (0)