Daemon Debugging These are common techniques for debugging daemons: Specifying a command line flag for the daemon to remain in the foreground Specifying a large sleep() command on startup to allow the programmer time to attach to the daemon Attaching gdb to a running daemon ('gdb ./fortuned `pidof ./fortuned`') Here is the relevant code from out main(): if (!stay_in_foreground){ daemonize(); if (sleep_on_start){ log("daemonized, now pid is '%d'", getpid()); sleep(20); } }