Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerate signals #13

Merged
merged 5 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: php-actions/composer@v5
- uses: php-actions/composer@v6

- name: Archive build
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./

- name: Upload build archive for test runners
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: /tmp/github-actions
Expand All @@ -31,7 +31,7 @@ jobs:
needs: [composer]

steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-artifact
path: /tmp/github-actions
Expand All @@ -40,10 +40,10 @@ jobs:
run: tar -xvf /tmp/github-actions/build.tar ./

- name: PHP Unit tests
uses: php-actions/phpunit@v2
uses: php-actions/phpunit@v3
with:
php_version: 8.0
php_extensions: xdebug
php_version: 8.1
php_extensions: xdebug pcntl
configuration: test/phpunit/phpunit.xml
bootstrap: vendor/autoload.php

Expand All @@ -52,7 +52,7 @@ jobs:
needs: [composer]

steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-artifact
path: /tmp/github-actions
Expand All @@ -61,6 +61,6 @@ jobs:
run: tar -xvf /tmp/github-actions/build.tar ./

- name: PHP Static Analysis
uses: php-actions/phpstan@v2
uses: php-actions/phpstan@v3
with:
path: src/
path: src/
4 changes: 2 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build:
environment:
php: 8.0.0
php: 8.1.0

nodes:
analysis:
Expand Down Expand Up @@ -29,4 +29,4 @@ checks:
filter:
excluded_paths:
- test/*
- vendor/*
- vendor/*
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"description": "Background script execution with cross-platform compatible streaming.",

"require": {
"php": ">=7.4"
"php": ">=7.4",
"ext-pcntl": "*"
},
"require-dev": {
"phpstan/phpstan": "^v1.8",
Expand Down
2 changes: 1 addition & 1 deletion src/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getPid():?int {
}

/** Closes the thread and the streams then returns the return code of the command. */
public function terminate(int $signal = 15):void {
public function terminate(int $signal = Signal::TERM):void {
if(!is_resource($this->process)) {
return;
}
Expand Down
42 changes: 42 additions & 0 deletions src/Signal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace Gt\Daemon;

/**
* Enumerator for POSIX signals
* @see https://en.wikipedia.org/wiki/Signal_(IPC)#POSIX_signals
*/
class Signal {
const ABRT = SIGABRT;
const ALRM = SIGALRM;
const BABY = SIGBABY;
const BUS = SIGBUS;
const CHLD = SIGCHLD;
const CLD = SIGCLD;
const CONT = SIGCONT;
const FPE = SIGFPE;
const HUP = SIGHUP;
const ILL = SIGILL;
const INT = SIGINT;
const IO = SIGIO;
const IOT = SIGIOT;
const KILL = SIGKILL;
const PIPE = SIGPIPE;
const POLL = SIGPOLL;
const PWR = SIGPWR;
const QUIT = SIGQUIT;
const URG = SIGURG;
const USR1 = SIGUSR1;
const USR2 = SIGUSR2;
const SEGV = SIGSEGV;
const STKFLT = SIGSTKFLT;
const STOP = SIGSTOP;
const SYS = SIGSYS;
const TSTP = SIGTSTP;
const TERM = SIGTERM;
const TTIN = SIGTTIN;
const TTOU = SIGTTOU;
const TRAP = SIGTRAP;
const WINCH = SIGWINCH;
const XCPU = SIGXCPU;
const XFSZ = SIGXFSZ;
}