Source: https://github.com/dubiousjim/dcron
Ever wonder how your cron jobs are being run? Today, we deep dive into the source code of a light-weight cron daemon written by Linux veteran Matthew Dillon. We learn all about daemon processes, the fork system call, and file redirection; we also see some of the standard practices and patterns around background jobs, job management, and signals.
Don't forget to like and SUBSCRIBE for more source code reviews like this one!
Errata:
At 15:05 I mention Dillon uses arbitrary braces to create an inner closure. While this is indeed a use case for this, there's another possible reason: in C89, declarations were only valid at the beginning of blocks. It's possible Dillon did this for backward compatibility with older compilers.