Checks if child or parent process and works accordingly