Fortuned's main() Function int main(int argc, char** argv) { int stay_in_foreground = 0; int sleep_on_start = 0; const char* device_file; parse_command_line(argc, argv, &stay_in_foreground, &sleep_on_start); open_log(argv[0]); device_file = get_fortune_device(); check_fortune_device(device_file); if (!stay_in_foreground){ daemonize(); if (sleep_on_start){ log("daemonized, now pid is '%d'", getpid()); sleep(20); } } handle_commands(device_file); close_log(); return 0; }