mirror of
https://github.com/danog/process.git
synced 2024-11-30 04:39:04 +01:00
Merge branch 'master' into v2-revolt
# Conflicts: # test/ProcessTest.php
This commit is contained in:
commit
bbe8032e16
138
.github/workflows/ci.yml
vendored
Normal file
138
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push: null
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
unit_tests:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '7.0'
|
||||
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '7.1'
|
||||
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '7.2'
|
||||
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '7.3'
|
||||
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '7.4'
|
||||
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '8.0'
|
||||
composer-flags: '--ignore-platform-req=php'
|
||||
|
||||
- operating-system: 'windows-latest'
|
||||
php-version: '8.0'
|
||||
composer-flags: '--ignore-platform-req=php'
|
||||
|
||||
- operating-system: 'macos-latest'
|
||||
php-version: '8.0'
|
||||
composer-flags: '--ignore-platform-req=php'
|
||||
|
||||
name: PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }}
|
||||
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
|
||||
- name: Use LF line ends
|
||||
run: |
|
||||
git config --global core.autocrlf false
|
||||
git config --global core.eol lf
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get Composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
|
||||
restore-keys: |
|
||||
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
|
||||
composer-${{ runner.os }}-${{ matrix.php-version }}-
|
||||
|
||||
- name: Install dependencies
|
||||
uses: nick-invision/retry@v2
|
||||
with:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 5
|
||||
retry_wait_seconds: 30
|
||||
command: |
|
||||
php_version=$(php -v)
|
||||
composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
|
||||
composer info -D
|
||||
|
||||
- name: Run unit tests
|
||||
run: vendor/bin/phpunit --verbose
|
||||
|
||||
coding_standards:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- operating-system: 'ubuntu-latest'
|
||||
php-version: '8.0'
|
||||
composer-flags: '--ignore-platform-req=php'
|
||||
|
||||
name: Coding standards
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
|
||||
- name: Use LF line ends
|
||||
run: |
|
||||
git config --global core.autocrlf false
|
||||
git config --global core.eol lf
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get Composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
|
||||
restore-keys: |
|
||||
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
|
||||
composer-${{ runner.os }}-${{ matrix.php-version }}-
|
||||
|
||||
- name: Install dependencies
|
||||
uses: nick-invision/retry@v2
|
||||
with:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 5
|
||||
retry_wait_seconds: 30
|
||||
command: |
|
||||
php_version=$(php -v)
|
||||
composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
|
||||
composer info -D
|
||||
|
||||
- name: Run style fixer
|
||||
env:
|
||||
PHP_CS_FIXER_IGNORE_ENV: 1
|
||||
run: vendor/bin/php-cs-fixer --diff --dry-run -v fix
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ coverage
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
vendor
|
||||
.phpunit.result.cache
|
6
.php_cs
6
.php_cs
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
$config = new Amp\CodeStyle\Config();
|
||||
$config = new Amp\CodeStyle\Config;
|
||||
$config->getFinder()
|
||||
->in(__DIR__ . '/examples')
|
||||
->in(__DIR__ . '/lib')
|
||||
->in(__DIR__ . '/test');
|
||||
|
||||
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
|
||||
|
||||
$config->setCacheFile($cacheDir . '/.php_cs.cache');
|
||||
$config->setCacheFile(__DIR__ . '/.php_cs.cache');
|
||||
|
||||
return $config;
|
||||
|
41
.travis.yml
41
.travis.yml
@ -1,41 +0,0 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4snapshot
|
||||
- nightly
|
||||
|
||||
sudo: false
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 7.4snapshot
|
||||
- php: nightly
|
||||
fast_finish: true
|
||||
|
||||
env:
|
||||
- AMP_DEBUG=true
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini || echo "No xdebug config."
|
||||
|
||||
install:
|
||||
- composer update -n --prefer-dist
|
||||
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v1.0.2/coveralls.phar
|
||||
- chmod +x coveralls.phar
|
||||
|
||||
script:
|
||||
- phpdbg -qrr vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml
|
||||
- PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer --diff --dry-run -v fix
|
||||
|
||||
after_script:
|
||||
- ./coveralls.phar -v
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.php-cs-fixer
|
||||
- $HOME/.local
|
@ -1,7 +1,6 @@
|
||||
# process
|
||||
|
||||
<p>
|
||||
<a href="https://travis-ci.org/amphp/process"><img src="https://img.shields.io/travis/amphp/process/master.svg?style=flat-square" alt="Build Status"/></a>
|
||||
<a href="https://coveralls.io/github/amphp/process?branch=master"><img src="https://img.shields.io/coveralls/amphp/process/master.svg?style=flat-square" alt="Code Coverage"/></a>
|
||||
<a href="https://github.com/amphp/process/releases"><img src="https://img.shields.io/github/release/amphp/process.svg?style=flat-square" alt="Release"/></a>
|
||||
<a href="https://github.com/amphp/process/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License"/></a>
|
||||
|
10
appveyor.yml
10
appveyor.yml
@ -8,21 +8,21 @@ platform:
|
||||
clone_folder: c:\projects\amphp
|
||||
|
||||
cache:
|
||||
- c:\tools\php74 -> appveyor.yml
|
||||
- c:\tools\php80 -> appveyor.yml
|
||||
|
||||
init:
|
||||
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php74;%PATH%
|
||||
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php80;%PATH%
|
||||
- SET COMPOSER_NO_INTERACTION=1
|
||||
- SET PHP=1
|
||||
- SET ANSICON=121x90 (121x90)
|
||||
|
||||
install:
|
||||
- IF EXIST c:\tools\php74 (SET PHP=0)
|
||||
- IF EXIST c:\tools\php80 (SET PHP=0)
|
||||
- IF %PHP%==1 sc config wuauserv start= auto
|
||||
- IF %PHP%==1 net start wuauserv
|
||||
- IF %PHP%==1 cinst -y OpenSSL.Light
|
||||
- IF %PHP%==1 cinst -y php
|
||||
- cd c:\tools\php74
|
||||
- cd c:\tools\php80
|
||||
- IF %PHP%==1 copy php.ini-production php.ini /Y
|
||||
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
|
||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
||||
@ -37,5 +37,5 @@ test_script:
|
||||
- cd c:\projects\amphp
|
||||
- phpdbg -qrr vendor/phpunit/phpunit/phpunit --colors=always --coverage-text --coverage-clover build/logs/clover.xml
|
||||
# Disable for now, because it can't be combined and files can't be shown on coveralls.io
|
||||
# https://github.com/php-coveralls/php-coveralls/issues/234
|
||||
# https://github.com/php-coveralls/php-coveralls/issues/234
|
||||
# - vendor/bin/coveralls -v
|
||||
|
@ -48,7 +48,7 @@
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.0.0"
|
||||
"php": "7.0.33"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -124,8 +124,8 @@ final class Runner implements ProcessRunner
|
||||
public function kill(ProcessHandle $handle): void
|
||||
{
|
||||
/** @var Handle $handle */
|
||||
// todo: send a signal to the wrapper to kill the child instead?
|
||||
if (!\proc_terminate($handle->proc)) {
|
||||
\exec('taskkill /F /T /PID ' . $handle->wrapperPid . ' 2>&1', $output, $exitCode);
|
||||
if ($exitCode) {
|
||||
throw new ProcessException("Terminating process failed");
|
||||
}
|
||||
|
||||
@ -226,12 +226,15 @@ final class Runner implements ProcessRunner
|
||||
$handle->stdin->close();
|
||||
$handle->stdout->close();
|
||||
$handle->stderr->close();
|
||||
|
||||
foreach ($handle->sockets as $socket) {
|
||||
@\fclose($socket);
|
||||
if (\is_resource($socket)) {
|
||||
@\fclose($socket);
|
||||
}
|
||||
}
|
||||
|
||||
@\fclose($handle->wrapperStderrPipe);
|
||||
if (\is_resource($handle->wrapperStderrPipe)) {
|
||||
@\fclose($handle->wrapperStderrPipe);
|
||||
}
|
||||
|
||||
if (\is_resource($handle->proc)) {
|
||||
\proc_close($handle->proc);
|
||||
|
@ -264,7 +264,10 @@ final class SocketConnector
|
||||
|
||||
// Explicitly \fclose() sockets, as resource streams shut only one side down.
|
||||
foreach ($handle->sockets as $sock) {
|
||||
@\fclose($sock);
|
||||
// Ensure socket is still open before attempting to close.
|
||||
if (\is_resource($sock)) {
|
||||
@\fclose($sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user