diff --git a/util.c b/util.c index bdf1aab..bc66018 100644 --- a/util.c +++ b/util.c @@ -113,6 +113,9 @@ int open_serial(const char *device, int rate) int fd = open(device, O_RDWR | O_NOCTTY); struct termios attr; + if (fd < 0) + return -1; + tcgetattr(fd, &attr); cfmakeraw(&attr); cfsetispeed(&attr, rate);