diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-04-13 02:17:19 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-04-13 02:17:19 +0300 |
commit | 7330a35806ffc1c91f0765d1fe19df2c459d5579 (patch) | |
tree | 489bad797be3bfadcb966bbfb290dd5044f74189 /src/main.php | |
parent | 544f2444211aa1ad9e3611818fb87e8a8882ff55 (diff) |
add signals example
Diffstat (limited to 'src/main.php')
-rw-r--r-- | src/main.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main.php b/src/main.php index 068263f..92531c8 100644 --- a/src/main.php +++ b/src/main.php @@ -10,19 +10,23 @@ Commands: test hello createfile + run_lrt + kill_lrt ID EOF; exit; } -$cmd = $argv[1]; +array_shift($argv); +$cmd = array_shift($argv); + $func = "cmd_{$cmd}"; if (!function_exists($func)) { echo red("command '".$cmd."' is not implemented")."\n"; exit(1); } -call_user_func($func); +call_user_func($func, $argv); /** Commands */ @@ -90,4 +94,15 @@ function cmd_hello() { function cmd_createfile() { $file = input('Enter file name: '); jobs::add(job_target::any, jobs\CreateFile::class, ['file' => $file]); +} + +function cmd_run_lrt() { + $ltr_id = jobs::add(job_target::low(1), jobs\LongRunningTask::class); + echo "id: $ltr_id\n"; +} + +function cmd_kill_lrt($argv) { + $id = $argv[0]; + $result = jobs::sendSignal($id, 15, job_target::low(1)); + var_dump($result); }
\ No newline at end of file |