@@ -119,12 +119,12 @@ class Process
119
119
/**
120
120
* Constructor.
121
121
*
122
- * @param string $commandline The command line to run
123
- * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
124
- * @param array|null $env The environment variables or null to inherit
125
- * @param string|null $stdin The STDIN content
126
- * @param integer |float|null $timeout The timeout in seconds or null to disable
127
- * @param array $options An array of options for proc_open
122
+ * @param string $commandline The command line to run
123
+ * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
124
+ * @param array|null $env The environment variables or null to inherit
125
+ * @param string|null $stdin The STDIN content
126
+ * @param int |float|null $timeout The timeout in seconds or null to disable
127
+ * @param array $options An array of options for proc_open
128
128
*
129
129
* @throws RuntimeException When proc_open is not installed
130
130
*
@@ -184,7 +184,7 @@ public function __clone()
184
184
* @param callback|null $callback A PHP callback to run whenever there is some
185
185
* output available on STDOUT or STDERR
186
186
*
187
- * @return integer The exit status code
187
+ * @return int The exit status code
188
188
*
189
189
* @throws RuntimeException When process can't be launch or is stopped
190
190
*
@@ -238,8 +238,20 @@ public function start($callback = null)
238
238
}
239
239
}
240
240
241
+ $ ptsWorkaround = null ;
242
+
243
+ if (!$ this ->useFileHandles && $ this ->enhanceSigchildCompatibility && $ this ->isSigchildEnabled ()) {
244
+ // Workaround for the bug, when PTS functionality is enabled.
245
+ // @see : https://bugs.php.net/69442
246
+ $ ptsWorkaround = fopen ('php://fd/0 ' , 'r ' );
247
+ }
248
+
241
249
$ this ->process = proc_open ($ commandline , $ descriptors , $ this ->processPipes ->pipes , $ this ->cwd , $ this ->env , $ this ->options );
242
250
251
+ if ($ ptsWorkaround ) {
252
+ fclose ($ ptsWorkaround );
253
+ }
254
+
243
255
if (!is_resource ($ this ->process )) {
244
256
throw new RuntimeException ('Unable to launch a new process. ' );
245
257
}
@@ -287,7 +299,7 @@ public function restart($callback = null)
287
299
*
288
300
* @param callback|null $callback A valid PHP callback
289
301
*
290
- * @return integer The exitcode of the process
302
+ * @return int The exitcode of the process
291
303
*
292
304
* @throws RuntimeException When process timed out
293
305
* @throws RuntimeException When process stopped after receiving signal
@@ -302,7 +314,7 @@ public function wait($callback = null)
302
314
do {
303
315
$ this ->checkTimeout ();
304
316
$ running = defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? $ this ->isRunning () : $ this ->processPipes ->hasOpenHandles ();
305
- $ close = !defined ('PHP_WINDOWS_VERSION_BUILD ' ) || !$ running ;;
317
+ $ close = !defined ('PHP_WINDOWS_VERSION_BUILD ' ) || !$ running ;
306
318
$ this ->readPipes (true , $ close );
307
319
} while ($ running );
308
320
@@ -324,7 +336,7 @@ public function wait($callback = null)
324
336
/**
325
337
* Returns the Pid (process identifier), if applicable.
326
338
*
327
- * @return integer |null The process id if running, null otherwise
339
+ * @return int |null The process id if running, null otherwise
328
340
*
329
341
* @throws RuntimeException In case --enable-sigchild is activated
330
342
*/
@@ -342,7 +354,8 @@ public function getPid()
342
354
/**
343
355
* Sends a posix signal to the process.
344
356
*
345
- * @param integer $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php)
357
+ * @param int $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php)
358
+ *
346
359
* @return Process
347
360
*
348
361
* @throws LogicException In case the process is not running
@@ -434,7 +447,7 @@ public function getIncrementalErrorOutput()
434
447
/**
435
448
* Returns the exit code returned by the process.
436
449
*
437
- * @return integer The exit status code
450
+ * @return int The exit status code
438
451
*
439
452
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
440
453
*
@@ -508,7 +521,7 @@ public function hasBeenSignaled()
508
521
*
509
522
* It is only meaningful if hasBeenSignaled() returns true.
510
523
*
511
- * @return integer
524
+ * @return int
512
525
*
513
526
* @throws RuntimeException In case --enable-sigchild is activated
514
527
*
@@ -546,7 +559,7 @@ public function hasBeenStopped()
546
559
*
547
560
* It is only meaningful if hasBeenStopped() returns true.
548
561
*
549
- * @return integer
562
+ * @return int
550
563
*
551
564
* @api
552
565
*/
@@ -612,10 +625,10 @@ public function getStatus()
612
625
/**
613
626
* Stops the process.
614
627
*
615
- * @param integer |float $timeout The timeout in seconds
616
- * @param integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL
628
+ * @param int |float $timeout The timeout in seconds
629
+ * @param int $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL
617
630
*
618
- * @return integer The exit-code of the process
631
+ * @return int The exit-code of the process
619
632
*
620
633
* @throws RuntimeException if the process got signaled
621
634
*/
@@ -704,7 +717,7 @@ public function getTimeout()
704
717
*
705
718
* To disable the timeout, set this value to null.
706
719
*
707
- * @param integer |float|null $timeout The timeout in seconds
720
+ * @param int |float|null $timeout The timeout in seconds
708
721
*
709
722
* @return self The current Process instance
710
723
*
@@ -728,7 +741,7 @@ public function setTimeout($timeout)
728
741
/**
729
742
* Enables or disables the TTY mode.
730
743
*
731
- * @param boolean $tty True to enabled and false to disable
744
+ * @param bool $tty True to enabled and false to disable
732
745
*
733
746
* @return self The current Process instance
734
747
*/
0 commit comments