Catch broken pipe errors in time sensor
authorSiraaj Khandkar <siraaj@khandkar.net>
Tue, 24 Mar 2020 22:57:58 +0000 (18:57 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Tue, 24 Mar 2020 22:57:58 +0000 (18:57 -0400)
x5/khatus_sensor_time.c

index ad170ef..869134c 100644 (file)
@@ -112,10 +112,18 @@ main(int argc, char **argv)
                for (i = 0; (n = write(fd, buf + i++, 1)) && r; r--)
                        ;
                if (n < 0)
                for (i = 0; (n = write(fd, buf + i++, 1)) && r; r--)
                        ;
                if (n < 0)
-                       fatal("Failed to write to %s. Err num: %d, Err msg: %s\n",
-                           fifo_name,
-                           errno,
-                           strerror(errno));
+                       switch (errno) {
+                       case EPIPE:
+                               error("Broken pipe. Msg buf: %s\n", buf);
+                               break;
+                       default:
+                               fatal(
+                                   "Failed to write to %s. "
+                                   "Err num: %d, Err msg: %s\n",
+                                   fifo_name,
+                                   errno,
+                                   strerror(errno));
+                       }
                if (close(fd) < 0)
                        fatal("Failed to close %s. Err num: %d, Err msg: %s\n",
                            fifo_name,
                if (close(fd) < 0)
                        fatal("Failed to close %s. Err num: %d, Err msg: %s\n",
                            fifo_name,
This page took 0.026529 seconds and 4 git commands to generate.