Open FIFO every 0.1 sec, add 'update'
This commit is contained in:
parent
d957f35af0
commit
0abc31cd76
|
@ -27,6 +27,9 @@ void execute_fifo_cmd(void) {
|
|||
drawmenu();
|
||||
} else if (!strcmp(fifot, "match")) {
|
||||
match();
|
||||
} else if (!strcmp(fifot, "update")) {
|
||||
match();
|
||||
drawmenu();
|
||||
} else if (!strcmp(fifot, "test")) {
|
||||
fprintf(stderr, "Test print\n");
|
||||
} else if (!strcmp(fifot, "die")) {
|
||||
|
@ -47,7 +50,7 @@ void execute_fifo_cmd(void) {
|
|||
|
||||
void *fifocmd(void *n) {
|
||||
for (;;) {
|
||||
sleep(1);
|
||||
msleep(0.1);
|
||||
|
||||
if (done) {
|
||||
execute_fifo_cmd();
|
||||
|
|
22
libs/main.c
22
libs/main.c
|
@ -1,5 +1,8 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#endif
|
||||
|
@ -85,3 +88,22 @@ void *ecalloc(size_t nmemb, size_t size) {
|
|||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
int msleep(long sec) {
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
if (sec < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ts.tv_sec = sec / 1000;
|
||||
ts.tv_nsec = (sec % 1000) * 1000000;
|
||||
|
||||
do {
|
||||
ret = nanosleep(&ts, &ts);
|
||||
} while (ret && errno == EINTR);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue