From: Siraaj Khandkar Date: Tue, 24 Mar 2020 22:57:58 +0000 (-0400) Subject: Catch broken pipe errors in time sensor X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=80e23f5474b94b36f66c0406425f2214d89eaf6e;p=khatus.git Catch broken pipe errors in time sensor --- diff --git a/x5/khatus_sensor_time.c b/x5/khatus_sensor_time.c index ad170ef..869134c 100644 --- a/x5/khatus_sensor_time.c +++ b/x5/khatus_sensor_time.c @@ -112,10 +112,18 @@ main(int argc, char **argv) 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,