39
39
use function posix_setuid ;
40
40
use function posix_geteuid ;
41
41
use function function_exists ;
42
+ use const DIRECTORY_SEPARATOR ;
42
43
use const PHP_OS ;
43
44
44
45
/**
@@ -66,7 +67,11 @@ public static function isTtySupported(): bool
66
67
static $ isTtySupported ;
67
68
68
69
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 );
70
75
}
71
76
72
77
return $ isTtySupported ;
@@ -85,7 +90,7 @@ public static function isPtySupported(): bool
85
90
return $ result ;
86
91
}
87
92
88
- if ('\\' === \ DIRECTORY_SEPARATOR ) {
93
+ if ('\\' === DIRECTORY_SEPARATOR ) {
89
94
return $ result = false ;
90
95
}
91
96
@@ -180,17 +185,13 @@ public static function daemonRun(Closure $beforeQuit = null): int
180
185
// chdir('/');
181
186
// umask(0);
182
187
break ;
183
-
184
188
case -1 : // fork failed.
185
189
throw new RuntimeException ('Fork new process is failed! exiting ' );
186
- break ;
187
-
188
190
default : // at parent
189
191
if ($ beforeQuit ) {
190
192
$ beforeQuit ($ pid );
191
193
}
192
-
193
- exit ;
194
+ exit (0 );
194
195
}
195
196
196
197
return $ pid ;
@@ -231,9 +232,9 @@ public static function forks(int $number, callable $onStart = null, callable $on
231
232
}
232
233
233
234
$ pidAry = [];
234
-
235
235
for ($ id = 0 ; $ id < $ number ; $ id ++) {
236
- $ info = self ::fork ($ onStart , $ onError , $ id );
236
+ $ info = self ::fork ($ onStart , $ onError , $ id );
237
+ // log
237
238
$ pidAry [$ info ['pid ' ]] = $ info ;
238
239
}
239
240
0 commit comments