// WTFPL #include #include #include #include #include "consts.h" #include "config.h" extern void light_thread(void); extern void keypress_thread(pid_t _light_pid); struct timeval* last_press; void daemonize(void) { daemon(0, 0); } int shared_mem_setup(void) { last_press = mmap(NULL, sizeof(last_press), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); return 0; // XXX error handling } int setup(void) { daemonize(); shared_mem_setup(); return 0; } int main(int argc, const char* argv[]) { setup(); pid_t keypress_pid = getpid(); pid_t light_pid = fork(); if (light_pid == 0) light_thread(); else keypress_thread(light_pid); return -1; }