Skip to content

ext/pcntl: pcntl_fork refining error handling. #14021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,26 @@ PHP_FUNCTION(pcntl_fork)
id = fork();
if (id == -1) {
PCNTL_G(last_error) = errno;
php_error_docref(NULL, E_WARNING, "Error %d", errno);
switch (errno) {
case EAGAIN:
php_error_docref(NULL, E_WARNING, "Error %d: Reached the maximum limit of number of processes", errno);
break;
case ENOMEM:
php_error_docref(NULL, E_WARNING, "Error %d: Insufficient memory", errno);
break;
// unlikely, especially nowadays.
case ENOSYS:
php_error_docref(NULL, E_WARNING, "Error %d: Unimplemented", errno);
break;
// QNX is the only platform returning it so far and is a different case from EAGAIN.
// Retries can be handled with sleep eventually.
case EBADF:
php_error_docref(NULL, E_WARNING, "Error %d: File descriptor concurrency issue", errno);
break;
default:
php_error_docref(NULL, E_WARNING, "Error %d", errno);

}
} else if (id == 0) {
zend_max_execution_timer_init();
}
Expand Down