// WTFPL #include #include #include #include #include "consts.h" #include "config.h" extern int light_thread(pid_t _keypress_pid); extern int 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 pid = fork(); if (pid == 0) return light_thread(keypress_pid); else return keypress_thread(/*light_*/pid); }