$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 */ }