@@ -64,7 +64,7 @@ public function __construct($cmd, $cwd = null, array $env = null)
6464 }
6565 }
6666
67- $ this ->enhanceSigchildCompatibility = $ this -> isSigchildEnabled ();
67+ $ this ->enhanceSigchildCompatibility = self :: isSigchildEnabled ();
6868 }
6969
7070 /**
@@ -91,7 +91,7 @@ public function start(LoopInterface $loop, $interval = 0.1)
9191 );
9292
9393 // Read exit code through fourth pipe to work around --enable-sigchild
94- if ($ this ->isSigchildEnabled () && $ this -> enhanceSigchildCompatibility ) {
94+ if ($ this ->enhanceSigchildCompatibility ) {
9595 $ fdSpec [] = array ('pipe ' , 'w ' );
9696 $ cmd = sprintf ('(%s) 3>/dev/null; code=$?; echo $code >&3; exit $code ' , $ cmd );
9797 }
@@ -152,7 +152,7 @@ public function close()
152152 $ this ->stdout ->close ();
153153 $ this ->stderr ->close ();
154154
155- if ($ this ->isSigchildEnabled () && $ this -> enhanceSigchildCompatibility ) {
155+ if ($ this ->enhanceSigchildCompatibility ) {
156156 $ this ->pollExitCodePipe ();
157157 $ this ->closeExitCodePipe ();
158158 }
@@ -203,38 +203,6 @@ public function getCommand()
203203 return $ this ->cmd ;
204204 }
205205
206- /**
207- * Return whether sigchild compatibility is enabled.
208- *
209- * @return boolean
210- */
211- public final function getEnhanceSigchildCompatibility ()
212- {
213- return $ this ->enhanceSigchildCompatibility ;
214- }
215-
216- /**
217- * Enable or disable sigchild compatibility mode.
218- *
219- * Sigchild compatibility mode is required to get the exit code and
220- * determine the success of a process when PHP has been compiled with
221- * the --enable-sigchild option.
222- *
223- * @param boolean $enhance
224- * @return self
225- * @throws RuntimeException If the process is already running
226- */
227- public final function setEnhanceSigchildCompatibility ($ enhance )
228- {
229- if ($ this ->isRunning ()) {
230- throw new \RuntimeException ('Process is already running ' );
231- }
232-
233- $ this ->enhanceSigchildCompatibility = (bool ) $ enhance ;
234-
235- return $ this ;
236- }
237-
238206 /**
239207 * Get the exit code returned by the process.
240208 *
@@ -347,6 +315,21 @@ public final static function isSigchildEnabled()
347315 return self ::$ sigchild = false !== strpos (ob_get_clean (), '--enable-sigchild ' );
348316 }
349317
318+ /**
319+ * Enable or disable sigchild compatibility mode.
320+ *
321+ * Sigchild compatibility mode is required to get the exit code and
322+ * determine the success of a process when PHP has been compiled with
323+ * the --enable-sigchild option.
324+ *
325+ * @param boolean $sigchild
326+ * @return void
327+ */
328+ public final static function setSigchildEnabled ($ sigchild )
329+ {
330+ self ::$ sigchild = (bool ) $ sigchild ;
331+ }
332+
350333 /**
351334 * Check the fourth pipe for an exit code.
352335 *
0 commit comments