[PECL-CVS] [pecl-networking-gearman] fix-fork-premature-job-completion: address reviews

[email protected] (Rasmus Lerdorf) Sat, 4 Apr 2026 14:32:01 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-04T10:31:56-04:00

Commit: https://github.com/php/pecl-networking-gearman/commit/cde5d303ba9a68b3d506ec7538b178810758f94e
Raw diff: https://github.com/php/pecl-networking-gearman/commit/cde5d303ba9a68b3d506ec7538b178810758f94e.diff

address reviews

Changed paths:
  M  php_gearman_client.h
  M  php_gearman_worker.h
  M  tests/gearman_worker_integration_test_003.phpt


Diff:

diff --git a/php_gearman_client.h b/php_gearman_client.h
index 6143652..416498a 100644
--- a/php_gearman_client.h
+++ b/php_gearman_client.h
@@ -16,6 +16,10 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
 #include "zend_exceptions.h"
 #include "zend_interfaces.h"
 
diff --git a/php_gearman_worker.h b/php_gearman_worker.h
index 521c93a..6e05d08 100644
--- a/php_gearman_worker.h
+++ b/php_gearman_worker.h
@@ -16,6 +16,10 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
 #include "zend_exceptions.h"
 #include "zend_interfaces.h"
 
diff --git a/tests/gearman_worker_integration_test_003.phpt b/tests/gearman_worker_integration_test_003.phpt
index f3bda40..21970aa 100644
--- a/tests/gearman_worker_integration_test_003.phpt
+++ b/tests/gearman_worker_integration_test_003.phpt
@@ -25,7 +25,9 @@ if ($wpid === 0) {
         $children = [];
         for ($i = 0; $i < 2; $i++) {
             $pid = pcntl_fork();
-            if ($pid === 0) {
+            if ($pid === -1) {
+                continue;
+            } elseif ($pid === 0) {
                 usleep(100000);
                 exit(0);
             }