2017-09-14 19:34:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Process\Internal;
|
|
|
|
|
2017-09-17 17:58:05 +02:00
|
|
|
use Amp\Process\ProcessException;
|
2017-09-14 19:34:18 +02:00
|
|
|
use Amp\Promise;
|
|
|
|
|
2018-10-15 06:16:09 +02:00
|
|
|
interface ProcessRunner
|
|
|
|
{
|
2017-09-14 19:34:18 +02:00
|
|
|
/**
|
2017-09-17 17:58:05 +02:00
|
|
|
* Start a process using the supplied parameters.
|
|
|
|
*
|
|
|
|
* @param string $command The command to execute.
|
|
|
|
* @param string|null $cwd The working directory for the child process.
|
|
|
|
* @param array $env Environment variables to pass to the child process.
|
|
|
|
* @param array $options `proc_open()` options.
|
|
|
|
*
|
|
|
|
* @return ProcessHandle
|
|
|
|
*
|
|
|
|
* @throws ProcessException If starting the process fails.
|
2017-09-14 19:34:18 +02:00
|
|
|
*/
|
2017-09-17 17:58:05 +02:00
|
|
|
public function start(string $command, string $cwd = null, array $env = [], array $options = []): ProcessHandle;
|
2017-09-14 19:34:18 +02:00
|
|
|
|
|
|
|
/**
|
2017-09-17 17:58:05 +02:00
|
|
|
* Wait for the child process to end.
|
|
|
|
*
|
|
|
|
* @param ProcessHandle $handle The process descriptor.
|
2017-09-14 19:34:18 +02:00
|
|
|
*
|
|
|
|
* @return Promise <int> Succeeds with exit code of the process or fails if the process is killed.
|
|
|
|
*/
|
2017-09-17 17:58:05 +02:00
|
|
|
public function join(ProcessHandle $handle): Promise;
|
2017-09-14 19:34:18 +02:00
|
|
|
|
|
|
|
/**
|
2017-09-17 17:58:05 +02:00
|
|
|
* Forcibly end the child process.
|
|
|
|
*
|
|
|
|
* @param ProcessHandle $handle The process descriptor.
|
2017-09-14 19:34:18 +02:00
|
|
|
*
|
2017-09-17 17:58:05 +02:00
|
|
|
* @throws ProcessException If terminating the process fails.
|
2017-09-14 19:34:18 +02:00
|
|
|
*/
|
2017-09-17 17:58:05 +02:00
|
|
|
public function kill(ProcessHandle $handle);
|
2017-09-14 19:34:18 +02:00
|
|
|
|
|
|
|
/**
|
2017-09-20 11:54:19 +02:00
|
|
|
* Send a signal signal to the child process.
|
2017-09-14 19:34:18 +02:00
|
|
|
*
|
2017-09-17 17:58:05 +02:00
|
|
|
* @param ProcessHandle $handle The process descriptor.
|
|
|
|
* @param int $signo Signal number to send to process.
|
|
|
|
*
|
|
|
|
* @throws ProcessException If sending the signal fails.
|
2017-09-14 19:34:18 +02:00
|
|
|
*/
|
2017-09-17 17:58:05 +02:00
|
|
|
public function signal(ProcessHandle $handle, int $signo);
|
2017-09-14 19:34:18 +02:00
|
|
|
|
|
|
|
/**
|
2017-09-17 17:58:05 +02:00
|
|
|
* Release all resources held by the process handle.
|
2017-09-14 19:34:18 +02:00
|
|
|
*
|
2017-09-17 17:58:05 +02:00
|
|
|
* @param ProcessHandle $handle The process descriptor.
|
2017-09-14 19:34:18 +02:00
|
|
|
*/
|
2017-09-17 17:58:05 +02:00
|
|
|
public function destroy(ProcessHandle $handle);
|
2017-09-14 19:34:18 +02:00
|
|
|
}
|