@@ -18,7 +18,7 @@ class ProcessUtil
18
18
* @var array
19
19
*/
20
20
public static $ signalMap = [
21
- SIGINT => 'SIGINT(Ctrl+C) ' ,
21
+ SIGINT => 'SIGINT(Ctrl+C) ' ,
22
22
SIGTERM => 'SIGTERM ' ,
23
23
SIGKILL => 'SIGKILL ' ,
24
24
SIGSTOP => 'SIGSTOP ' ,
@@ -28,7 +28,7 @@ class ProcessUtil
28
28
* fork/create a child process.
29
29
* @param callable|null $onStart Will running on the child process start.
30
30
* @param callable|null $onError
31
- * @param int $id The process index number. will use `forks()`
31
+ * @param int $id The process index number. will use `forks()`
32
32
* @return array|false
33
33
* @throws \RuntimeException
34
34
*/
@@ -44,8 +44,8 @@ public static function fork(callable $onStart = null, callable $onError = null,
44
44
// at parent, get forked child info
45
45
if ($ pid > 0 ) {
46
46
$ info = [
47
- 'id ' => $ id ,
48
- 'pid ' => $ pid ,
47
+ 'id ' => $ id ,
48
+ 'pid ' => $ pid ,
49
49
'startTime ' => \time (),
50
50
];
51
51
} elseif ($ pid === 0 ) { // at child
@@ -69,7 +69,7 @@ public static function fork(callable $onStart = null, callable $onError = null,
69
69
* @see ProcessUtil::fork()
70
70
* @param callable|null $onStart
71
71
* @param callable|null $onError
72
- * @param int $id
72
+ * @param int $id
73
73
* @return array|false
74
74
* @throws \RuntimeException
75
75
*/
@@ -122,7 +122,7 @@ public static function daemonRun(\Closure $beforeQuit = null): int
122
122
123
123
/**
124
124
* @see ProcessUtil::forks()
125
- * @param int $number
125
+ * @param int $number
126
126
* @param callable|null $onStart
127
127
* @param callable|null $onError
128
128
* @return array|false
@@ -135,7 +135,7 @@ public static function multi(int $number, callable $onStart = null, callable $on
135
135
136
136
/**
137
137
* fork/create multi child processes.
138
- * @param int $number
138
+ * @param int $number
139
139
* @param callable|null $onStart Will running on the child processes.
140
140
* @param callable|null $onError
141
141
* @return array|false
@@ -198,7 +198,7 @@ public static function wait(callable $onExit): bool
198
198
* ],
199
199
* ... ...
200
200
* ]
201
- * @param int $signal
201
+ * @param int $signal
202
202
* @param array $events
203
203
* [
204
204
* 'beforeStops' => function ($sigText) {
@@ -222,7 +222,7 @@ public static function stopWorkers(array $children, int $signal = \SIGTERM, arra
222
222
223
223
$ events = \array_merge ([
224
224
'beforeStops ' => null ,
225
- 'beforeStop ' => null ,
225
+ 'beforeStop ' => null ,
226
226
], $ events );
227
227
228
228
if ($ cb = $ events ['beforeStops ' ]) {
@@ -247,9 +247,9 @@ public static function stopWorkers(array $children, int $signal = \SIGTERM, arra
247
247
248
248
/**
249
249
* send kill signal to the process
250
- * @param int $pid
250
+ * @param int $pid
251
251
* @param bool $force
252
- * @param int $timeout
252
+ * @param int $timeout
253
253
* @return bool
254
254
*/
255
255
public static function kill (int $ pid , bool $ force = false , int $ timeout = 3 ): bool
@@ -259,10 +259,10 @@ public static function kill(int $pid, bool $force = false, int $timeout = 3): bo
259
259
260
260
/**
261
261
* Do shutdown process and wait it exit.
262
- * @param int $pid Master Pid
263
- * @param bool $force
264
- * @param int $waitTime
265
- * @param null $error
262
+ * @param int $pid Master Pid
263
+ * @param bool $force
264
+ * @param int $waitTime
265
+ * @param null $error
266
266
* @param string $name
267
267
* @return bool
268
268
*/
@@ -272,8 +272,7 @@ public static function killAndWait(
272
272
$ name = 'process ' ,
273
273
bool $ force = false ,
274
274
int $ waitTime = 10
275
- ): bool
276
- {
275
+ ): bool {
277
276
// do stop
278
277
if (!self ::kill ($ pid , $ force )) {
279
278
$ error = "Send stop signal to the $ name(PID: $ pid) failed! " ;
@@ -333,7 +332,7 @@ public static function quit($code = 0)
333
332
334
333
/**
335
334
* 杀死所有进程
336
- * @param $name
335
+ * @param $name
337
336
* @param int $sigNo
338
337
* @return string
339
338
*/
@@ -397,7 +396,7 @@ public static function sendSignal(int $pid, int $signal, int $timeout = 0): bool
397
396
398
397
/**
399
398
* install signal
400
- * @param int $signal e.g: SIGTERM SIGINT(Ctrl+C) SIGUSR1 SIGUSR2 SIGHUP
399
+ * @param int $signal e.g: SIGTERM SIGINT(Ctrl+C) SIGUSR1 SIGUSR2 SIGHUP
401
400
* @param callable $handler
402
401
* @return bool
403
402
*/
@@ -468,7 +467,7 @@ public static function getPid(): int
468
467
/**
469
468
* get PID by pid File
470
469
* @param string $file
471
- * @param bool $checkLive
470
+ * @param bool $checkLive
472
471
* @return int
473
472
*/
474
473
public static function getPidByFile (string $ file , bool $ checkLive = false ): int
@@ -506,7 +505,7 @@ public static function getCurrentUser(): array
506
505
* ProcessUtil::clearAlarm(); // close
507
506
* }
508
507
* });
509
- * @param int $seconds
508
+ * @param int $seconds
510
509
* @param callable $handler
511
510
* @return bool|int
512
511
*/
@@ -531,7 +530,7 @@ public static function clearAlarm(): int
531
530
532
531
/**
533
532
* run a command. it is support windows
534
- * @param string $command
533
+ * @param string $command
535
534
* @param string|null $cwd
536
535
* @return array
537
536
* @throws \RuntimeException
0 commit comments