Our Daemonize() Function- Cont'd /* change our working directory to /, to make sure umounting the file system where we started is possible */ chdir("/"); /* set out umask to 0, to make sure we fully control our file creating bits */ umask(0); /* close all (possibly) open file descriptors */ /* TODO: calling getdtablesize() here loops endlessly. why? */ for (i = 0; i < MAXFD ; i++) close(i); log("succesfully daemonized"); }