- nonblock = (connector || !modem)? O_NONBLOCK: 0;
- if ((ttyfd = open(devnam, nonblock | O_RDWR, 0)) < 0) {
- syslog(LOG_ERR, "Failed to open %s: %m", devnam);
- goto fail;
- }
- if (nonblock) {
- if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
- || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
- syslog(LOG_WARNING,
- "Couldn't reset non-blocking mode on device: %m");
+ while ((ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0)) < 0) {
+ if (errno != EINTR)
+ syslog(LOG_ERR, "Failed to open %s: %m", devnam);
+ if (!persist || errno != EINTR)
+ goto fail;