cocur / background-process

Start processes in the background that continue running when the PHP process exists.
MIT License
295 stars 61 forks source link

Stop Process By ID #11

Closed giselajesslim closed 9 years ago

giselajesslim commented 9 years ago

How to stop process by ID? I am using stable version. Thanks.

$process = new BackgroundProcess('/usr/bin/php queue.php');
        if ($process->isRunning(15371)) {
            $process->stop();
        }
florianeckerstorfer commented 9 years ago

BackgroundProcess handles the PID internally. The parameter you passed to isPassing() does actually do nothing. If you want to stop a process manually by PID you can check out the source code of the stop() method. See https://github.com/cocur/background-process/blob/master/src/BackgroundProcess.php#L94