'C Linux deamon only doing one iteration of a main loop

I have created a deamon for linux in C. It is meant to copy contents of folder A to folder B in 5 seconds intervals. Child process only copies the contents once and dies.

pid_t pid, sid;

pid = fork();
if (pid < 0)
{
    exit(EXIT_FAILURE);
}

if (pid > 0)
{
    exit(EXIT_SUCCESS);
}
umask(0);

sid = setsid();
if (sid < 0)
{
    /* Log the failure */
    exit(EXIT_FAILURE);
}

close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);

while (1)
{

    serialize(argv[1], argv[2]);
    sleep(5);
}
exit(EXIT_SUCCESS);

}

Any help would be great! :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source