diff --git a/main.c b/main.c index c954630..5b3f037 100644 --- a/main.c +++ b/main.c @@ -101,6 +101,26 @@ void readToHost(char *host, FILE *hostsFile) } } +/** + * Daemonize the process, to be run like this ONLY if there were no arguments + * provided. + * + * TODO: + * read the config file. + */ +void daemonize() { + pid_t mypid = fork(); + if (mypid != 0) { + // I am the parent, kill myself + fprintf(stderr, "Parent exiting"); + exit(1); + } + + else { + // DO THE THING. + } +} + /** * Entrypoint. */ @@ -142,6 +162,9 @@ int main(int argc, char **argv) { showHosts(); } + else { + daemonize(); + } } if (hostsFile != NULL)