]> git.mdlowis.com Git - projs/tide.git/commitdiff
added check if telemetry file is a fifo
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 31 Oct 2019 02:36:34 +0000 (22:36 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 31 Oct 2019 02:36:34 +0000 (22:36 -0400)
src/lib/argv0.c
src/lib/telem.c

index 9adafa9b39de2482318523377df268202bfbb631..1b4ebb6bcbc56ef0431f08d70a57984c3038c59e 100644 (file)
@@ -1 +1 @@
-char* ARGV0 = NULL;
\ No newline at end of file
+char* ARGV0 = NULL;
index bfb96dcfed2f4b584104441600e259fb3687c9c7..ee9dc9402d08b0c8705e1a70f74bb66ae81170df 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdc.h>
 #include <time.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <pwd.h>
 #include <io.h>
 
@@ -13,8 +14,12 @@ static int open_telem(char* path)
     unsigned long curr = time(NULL);
     if ((TelemFd < 0) && ((curr - prev) >= 1))
     {
-        TelemFd = open(path, O_WRONLY|O_NONBLOCK, 0);
-        prev = curr;
+        struct stat st = {0};
+        if ((stat(path, &st) >= 0) && S_ISFIFO(st.st_mode))
+        {
+            TelemFd = open(path, O_WRONLY|O_NONBLOCK, 0);
+            prev = curr;
+        }
     }
     return TelemFd;
 }