Skip to content

Commit

Permalink
Fixed shared memory writing and fork losing received messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ghola committed Mar 17, 2016
1 parent 530fcf5 commit b01c68f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Spork/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Fork implements DeferredInterface
private $name;
private $status;
private $message;
private $messages = array();

public function __construct($pid, SharedMemory $shm, $debug = false)
{
Expand Down Expand Up @@ -92,17 +93,15 @@ public function processWaitStatus($status)

public function receive()
{
$messages = array();

foreach ($this->shm->receive() as $message) {
if ($message instanceof ExitMessage) {
$this->message = $message;
} else {
$messages[] = $message;
$this->messages[] = $message;
}
}

return $messages;
return $this->messages;
}

public function kill($signal = SIGINT)
Expand Down Expand Up @@ -135,6 +134,11 @@ public function getError()
}
}

public function getMessages()
{
return $this->messages;
}

public function isSuccessful()
{
return 0 === $this->getExitStatus();
Expand Down

0 comments on commit b01c68f

Please sign in to comment.