If the fork works but the execlp doesn't, that's when that line will be printed, and only in the child process.
If for some reason the fork fails (for example, you've exceeded resource quotas), no child is created and the parent will simply go through the if (pid < 0) code.
If both the fork and the execlp work, execlp replaces the contents of the child process with the /bin/ls executable so no code in the original program exists after that point.
There are several ways the execlp could fail, among them (not an exhaustive list):
the permissions forbid it.
some prankster has moved or deleted the /bin/ls executable.
it exists elsewhere else in the file system (a).
it's been corrupted.
If the fork works but the execlp doesn't, that's when that line will be printed, and only in the child process.If for some reason the fork fails (for example, you've exceeded resource quotas), no child is created and the parent will simply go through the if (pid < 0) code.If both the fork and the execlp work, execlp replaces the contents of the child process with the /bin/ls executable so no code in the original program exists after that point.There are several ways the execlp could fail, among them (not an exhaustive list):the permissions forbid it.some prankster has moved or deleted the /bin/ls executable.it exists elsewhere else in the file system (a).it's been corrupted.
การแปล กรุณารอสักครู่..
