Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 6e1379b

Browse files
authored
Merge pull request #262 from pmorjan/wait-for-indexfile
init: wait for ifindex file
2 parents 4f0e9ec + b3ed567 commit 6e1379b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <arpa/inet.h>
99
#include <fcntl.h>
1010
#include <termios.h>
11+
#include <sched.h>
1112

1213
#include "hyper.h"
1314
#include "util.h"
@@ -169,6 +170,10 @@ static int hyper_get_ifindex(char *nic)
169170
sprintf(path, "/sys/class/net/%s/ifindex", nic);
170171
fprintf(stdout, "net device sys path is %s\n", path);
171172

173+
while (access(path, R_OK) < 0) {
174+
sched_yield();
175+
}
176+
172177
fd = open(path, O_RDONLY);
173178
if (fd < 0) {
174179
perror("can not open file");

0 commit comments

Comments
 (0)