What daemon() does is that it forks a new process (with a different process id) so at some point, until the parent process exits, you have two identical processes with different ids. Please read man fork for more details.