th pid is returned in the parent, so your condition should be
if (!pid)
because the child in your code will not go to the if. that's because
On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no child process is created, and errno is set appropriately.