aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorspv <spv@spv.sh>2025-09-21 00:59:56 -0400
committerspv <spv@spv.sh>2025-09-21 00:59:56 -0400
commit02a74cc0b499f6a93c25ea8cd392af977298d60a (patch)
tree71b9008bdb6402e10477c9f80fe43950f7c89c72 /src/main.c
parent38d25483657e82eb546ecb8566214f830efba461 (diff)
use signal ipc instead of sleep loop
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 4c09563..5c57bbf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -8,8 +8,8 @@
#include "consts.h"
#include "config.h"
-extern int light_thread(void);
-extern int keypress_thread(void);
+extern int light_thread(pid_t _keypress_pid);
+extern int keypress_thread(pid_t _light_pid);
struct timeval* last_press;
@@ -33,6 +33,9 @@ int setup(void) {
int main(int argc, const char* argv[]) {
setup();
- if (fork() == 0) return light_thread();
- else return keypress_thread();
+ pid_t keypress_pid = getpid();
+ pid_t pid = fork();
+
+ if (pid == 0) return light_thread(keypress_pid);
+ else return keypress_thread(/*light_*/pid);
}