feat: emulate rust's process api more closely
Yoink some docs as well
This commit is contained in:
@@ -4,15 +4,53 @@ declare(strict_types=1);
|
||||
|
||||
namespace Nih\CommandBuilder;
|
||||
|
||||
/**
|
||||
* Describes the result of a process after it has terminated.
|
||||
*
|
||||
* This class is used to represent the exit status or other termination of a
|
||||
* child process. Child processes are created via the {@see Command} class and
|
||||
* their exit status is exposed through the status method, or the wait method of
|
||||
* a Child process.
|
||||
*/
|
||||
final class ExitStatus
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $code,
|
||||
private readonly ?int $code,
|
||||
private readonly ?int $signal = null,
|
||||
private readonly ?int $stoppedSignal = null,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Was termination successful? Signal termination is not considered a
|
||||
* success, and success is defined as a zero exit status.
|
||||
*/
|
||||
public function success(): bool
|
||||
{
|
||||
return $this->code === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The exit code of the process, if any.
|
||||
*/
|
||||
public function code(): ?int
|
||||
{
|
||||
return $this->code > -1 ? $this->code : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the process was terminated by a signal, returns that signal.
|
||||
*/
|
||||
public function signal(): ?int
|
||||
{
|
||||
return $this->signal;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the process was stopped by a signal, returns that signal.
|
||||
*/
|
||||
public function stoppedSignal(): ?int
|
||||
{
|
||||
return $this->stoppedSignal;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user