Skip to content

Commit

Permalink
Add stop() method to Process and Pool (#52959)
Browse files Browse the repository at this point in the history
* feat: Add stop() convenience method to InvokedProcess

* feat: Added stop() helper method to process pools as well

* Update InvokedProcess.php

* Update InvokedProcessPool.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
MiniCodeMonkey and taylorotwell authored Sep 27, 2024
1 parent bb85cbe commit e1f1cde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Illuminate/Process/InvokedProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ public function signal(int $signal)
return $this;
}

/**
* Stop the process if it is still running.
*
* @param float $timeout
* @param int|null $signal
*
* @return int|null
*/
public function stop(float $timeout = 10, ?int $signal = null)
{
return $this->process->stop($timeout, $signal);
}

/**
* Determine if the process is still running.
*
Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Process/InvokedProcessPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public function signal(int $signal)
return $this->running()->each->signal($signal);
}

/**
* Stop all processes that are still running
*
* @param float $timeout
* @param int|null $signal
*
* @return \Illuminate\Support\Collection
*/
public function stop(float $timeout = 10, ?int $signal = null)
{
return $this->running()->each->stop($timeout, $signal);
}

/**
* Get the processes in the pool that are still currently running.
*
Expand Down

0 comments on commit e1f1cde

Please sign in to comment.