Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/GO/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class Job
*/
private $id;

/**
* PID.
*
* @var string
*/
private $pid = null;

/**
* Command to execute.
*
Expand Down Expand Up @@ -175,6 +182,16 @@ public function getId()
return $this->id;
}

/**
* Get the PID.
*
* @return string
*/
public function getPid()
{
return $this->pid;
}

/**
* Check if the Job is due to run.
* It accepts as input a DateTime used to check if
Expand Down Expand Up @@ -308,7 +325,7 @@ public function compile()
if ($this->canRunInBackground()) {
// Parentheses are need execute the chain of commands in a subshell
// that can then run in background
$compiled = '(' . $compiled . ') > /dev/null 2>&1 &';
$compiled = '(' . $compiled . ') > /dev/null 2>&1 & echo $!';
}

return trim($compiled);
Expand Down Expand Up @@ -380,6 +397,7 @@ public function run()
$this->output = $this->exec($compiled);
} else {
exec($compiled, $this->output, $this->returnCode);
$this->pid = intval($this->output[0]);
}

$this->finalise();
Expand Down