2020-12-11 13:23:57 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Toalett\Multiprocessing\ProcessControl;
|
|
|
|
|
|
|
|
class Fork
|
|
|
|
{
|
2020-12-12 13:05:48 +01:00
|
|
|
public int $pid;
|
2020-12-11 13:23:57 +01:00
|
|
|
|
2020-12-12 13:05:48 +01:00
|
|
|
public function __construct(int $pid)
|
|
|
|
{
|
|
|
|
$this->pid = $pid;
|
|
|
|
}
|
2020-12-11 13:23:57 +01:00
|
|
|
|
2020-12-12 13:05:48 +01:00
|
|
|
public function failed(): bool
|
|
|
|
{
|
|
|
|
return $this->pid < 0;
|
|
|
|
}
|
2020-12-11 13:23:57 +01:00
|
|
|
|
2020-12-12 13:05:48 +01:00
|
|
|
public function isChild(): bool
|
|
|
|
{
|
|
|
|
return $this->pid === 0;
|
|
|
|
}
|
2020-12-11 13:23:57 +01:00
|
|
|
|
2020-12-12 13:05:48 +01:00
|
|
|
public function isParent(): bool
|
|
|
|
{
|
|
|
|
return $this->pid !== 0;
|
|
|
|
}
|
2020-12-11 13:23:57 +01:00
|
|
|
}
|