blob: 497e8d49a225284b99ea74d12b97b33a238fe93e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
$NetBSD: patch-ad,v 1.2 2003/01/10 04:30:19 rh Exp $
--- libpisock/unixserial.c.orig Tue Dec 3 00:32:47 2002
+++ libpisock/unixserial.c
@@ -178,13 +178,23 @@ s_open(struct pi_socket *ps, struct pi_s
i;
char *tty = addr->pi_device;
struct pi_serial_data *data = (struct pi_serial_data *)ps->device->data;
+#define maxretries 100
+ int retries;
#ifndef SGTTY
struct termios tcn;
#else
struct sgttyb tcn;
#endif
- if ((fd = open(tty, O_RDWR | O_NONBLOCK)) == -1) {
+
+ for (retries = 0 ; retries <= maxretries ; retries++ ) {
+ if ((fd = open(tty, O_RDWR | O_NONBLOCK)) != -1) {
+ break;
+ }
+ usleep(50000);
+ }
+
+ if (fd == -1) {
return -1; /* errno already set */
}
|