Skip to content

Commit

Permalink
Set PID of process to allow working with already running processes
Browse files Browse the repository at this point in the history
Allow resume the process any time by setting process id
  • Loading branch information
Florian Eckerstorfer authored Feb 11, 2017
2 parents f23640f + d630c21 commit db3c7b9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/BackgroundProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BackgroundProcess
*
* @codeCoverageIgnore
*/
public function __construct($command)
public function __construct($command = null)
{
$this->command = $command;
$this->serverOS = $this->getOS();
Expand All @@ -62,6 +62,7 @@ public function __construct($command)
*/
public function run($outputFile = '/dev/null', $append = false)
{
if(is_null($this->command)) return;
switch ($this->getOS()) {
case self::OS_WINDOWS:
shell_exec(sprintf('%s &', $this->command, $outputFile));
Expand Down Expand Up @@ -133,6 +134,16 @@ public function getPid()

return $this->pid;
}

/**
* Set the process id.
*
* @param $pid
*/
public function setPid($pid)
{
$this->pid = $pid;
}

/**
* @return int
Expand Down

0 comments on commit db3c7b9

Please sign in to comment.