Open FIFO every 0.1 sec, add 'update'

This commit is contained in:
Jacob 2023-08-08 22:14:29 +02:00
parent d957f35af0
commit 0abc31cd76
2 changed files with 26 additions and 1 deletions

View file

@ -27,6 +27,9 @@ void execute_fifo_cmd(void) {
drawmenu(); drawmenu();
} else if (!strcmp(fifot, "match")) { } else if (!strcmp(fifot, "match")) {
match(); match();
} else if (!strcmp(fifot, "update")) {
match();
drawmenu();
} else if (!strcmp(fifot, "test")) { } else if (!strcmp(fifot, "test")) {
fprintf(stderr, "Test print\n"); fprintf(stderr, "Test print\n");
} else if (!strcmp(fifot, "die")) { } else if (!strcmp(fifot, "die")) {
@ -47,7 +50,7 @@ void execute_fifo_cmd(void) {
void *fifocmd(void *n) { void *fifocmd(void *n) {
for (;;) { for (;;) {
sleep(1); msleep(0.1);
if (done) { if (done) {
execute_fifo_cmd(); execute_fifo_cmd();

View file

@ -1,5 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <time.h>
#ifndef MAX #ifndef MAX
#define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B))
#endif #endif
@ -85,3 +88,22 @@ void *ecalloc(size_t nmemb, size_t size) {
die("calloc:"); die("calloc:");
return p; 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;
}