8 #include "khatus_lib_log.h"
9 #include "khatus_lib_sensor.h"
10 #include "khatus_lib_time.h"
13 loop(struct timespec
*ti
, char *fifo
, char *buf
, int fun(char *))
16 int w
= -1; /* written */
17 int r
= -1; /* remaining */
18 int i
= -1; /* buffer position */
21 debug("openning \"%s\"\n", fifo
);
22 fd
= open(fifo
, O_WRONLY
);
24 fatal("Failed to open FIFO file: \"%s\". Error: %s\n",
27 debug("openned. fd: %d\n", fd
);
29 buf
[r
] = END_OF_MESSAGE
;
30 for (i
= 0; (w
= write(fd
, buf
+ i
++, 1)) && r
; r
--)
35 error("Broken pipe. Msg buf: %s\n", buf
);
39 "Failed to write to %s. "
40 "Err num: %d, Err msg: %s\n",
46 fatal("Failed to close %s. Err num: %d, Err msg: %s\n",
51 debug("closed. fd: %d\n", fd
);
This page took 0.07153 seconds and 4 git commands to generate.