[php-src] master: ext/pcntl: pcntl_fork refining error handling. (#14021)
| From: | David CARLIER via GitHub | Date: | Sat, 20 Apr 2024 20:01:16 +0000 |
| Subject: | [php-src] master: ext/pcntl: pcntl_fork refining error handling. (#14021) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128182@lists.php.net to get a copy of this message | ||
Author: David CARLIER (devnexen)
Committer: GitHub (web-flow)
Pusher: devnexen
Date: 2024-04-20T21:01:09+01:00
Commit: https://github.com/php/php-src/commit/23640542dcc157cc875b7e42b957d0d11edf6905
Raw diff: https://github.com/php/php-src/commit/23640542dcc157cc875b7e42b957d0d11edf6905.diff
ext/pcntl: pcntl_fork refining error handling. (#14021)
Changed paths:
M ext/pcntl/pcntl.c
Diff:
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 1c09253f8dfd5..229d66c73c116 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -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();
}