summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2016-01-04 19:12:40 -0500
committerEric S. Raymond <esr@thyrsus.com>2016-01-04 19:12:40 -0500
commit469f00e0ba8792e82278f40e69057cda8be1c193 (patch)
tree508c8214be260f51b7024f426033b8e1ae510e7f /serial.c
parent46127111c3cad66f6ec1e6db1d75e3db063fd1a0 (diff)
downloadgpsd-469f00e0ba8792e82278f40e69057cda8be1c193.tar.gz
Address Savannah bug #45270: serial driver does not work properly on pipes.
Simon Artott wrote: When using a pipe with the serial driver (e.g. stdin from another process) to provide NMEA data, the fd is set to blocking mode and gpsd_poll() gets stuck in a loop calling get_packet() because read() always waits for more data. I have to remove the "Switch back to blocking I/O now that CLOCAL is set" code from serial.c to get it to work. The driver should detect if the fd is a pipe and keep it set to non-blocking.
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/serial.c b/serial.c
index 5e67fb1f..d8bdd8c7 100644
--- a/serial.c
+++ b/serial.c
@@ -51,6 +51,8 @@ static sourcetype_t gpsd_classify(const char *path)
return source_pty;
else if (strncmp(path, "/dev/pps", 8) == 0)
return source_pps;
+ else if (S_ISFIFO(sb.st_mode))
+ return source_pipe;
else if (S_ISCHR(sb.st_mode)) {
sourcetype_t devtype = source_rs232;
#ifdef __linux__
@@ -579,7 +581,8 @@ int gpsd_serial_open(struct gps_device_t *session)
);
}
- /* Switch back to blocking I/O now that CLOCAL is set. */
+ /* Probably want to switch back to blocking I/O now that CLOCAL is set. */
+ if (session->sourcetype != source_pipe)
{
int oldfl = fcntl(session->gpsdata.gps_fd, F_GETFL);
if (oldfl != -1)