3939use function posix_setuid ;
4040use function posix_geteuid ;
4141use function function_exists ;
42+ use const DIRECTORY_SEPARATOR ;
4243use const PHP_OS ;
4344
4445/**
@@ -66,7 +67,11 @@ public static function isTtySupported(): bool
6667 static $ isTtySupported ;
6768
6869 if (null === $ isTtySupported ) {
69- $ isTtySupported = (bool ) @proc_open ('echo 1 >/dev/null ' , [['file ' , '/dev/tty ' , 'r ' ], ['file ' , '/dev/tty ' , 'w ' ], ['file ' , '/dev/tty ' , 'w ' ]], $ pipes );
70+ $ isTtySupported = (bool )@proc_open ('echo 1 >/dev/null ' , [
71+ ['file ' , '/dev/tty ' , 'r ' ],
72+ ['file ' , '/dev/tty ' , 'w ' ],
73+ ['file ' , '/dev/tty ' , 'w ' ]
74+ ], $ pipes );
7075 }
7176
7277 return $ isTtySupported ;
@@ -85,7 +90,7 @@ public static function isPtySupported(): bool
8590 return $ result ;
8691 }
8792
88- if ('\\' === \ DIRECTORY_SEPARATOR ) {
93+ if ('\\' === DIRECTORY_SEPARATOR ) {
8994 return $ result = false ;
9095 }
9196
@@ -180,17 +185,13 @@ public static function daemonRun(Closure $beforeQuit = null): int
180185 // chdir('/');
181186 // umask(0);
182187 break ;
183-
184188 case -1 : // fork failed.
185189 throw new RuntimeException ('Fork new process is failed! exiting ' );
186- break ;
187-
188190 default : // at parent
189191 if ($ beforeQuit ) {
190192 $ beforeQuit ($ pid );
191193 }
192-
193- exit ;
194+ exit (0 );
194195 }
195196
196197 return $ pid ;
@@ -231,9 +232,9 @@ public static function forks(int $number, callable $onStart = null, callable $on
231232 }
232233
233234 $ pidAry = [];
234-
235235 for ($ id = 0 ; $ id < $ number ; $ id ++) {
236- $ info = self ::fork ($ onStart , $ onError , $ id );
236+ $ info = self ::fork ($ onStart , $ onError , $ id );
237+ // log
237238 $ pidAry [$ info ['pid ' ]] = $ info ;
238239 }
239240
0 commit comments