Symfony\Component\Process\Process::signal PHP 메소드

signal() 공개 메소드

Sends a POSIX signal to the process.
public signal ( integer $signal ) : Process
$signal integer A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
리턴 Process
    public function signal($signal)
    {
        $this->doSignal($signal, true);
        return $this;
    }

Usage Example

예제 #1
0
 public function testControlledExit()
 {
     if (!extension_loaded('pcntl')) {
         $this->markTestSkipped('PCNTL extension is not loaded.');
     }
     $proc = new Process('exec ' . PHP_BINARY . ' ' . escapeshellarg(__DIR__ . '/console') . ' jms-job-queue:run --worker-name=test --verbose --max-runtime=999999');
     $proc->start();
     usleep(500000.0);
     $this->assertTrue($proc->isRunning(), 'Process exited prematurely: ' . $proc->getOutput() . $proc->getErrorOutput());
     $this->assertTrueWithin(3, function () use($proc) {
         return false !== strpos($proc->getOutput(), 'Signal Handlers have been installed');
     }, function () use($proc) {
         $this->fail('Signal handlers were not installed: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $proc->signal(SIGTERM);
     $this->assertTrueWithin(3, function () use($proc) {
         return false !== strpos($proc->getOutput(), 'Received SIGTERM');
     }, function () use($proc) {
         $this->fail('Signal was not received by process within 3 seconds: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $this->assertTrueWithin(3, function () use($proc) {
         return !$proc->isRunning();
     }, function () use($proc) {
         $this->fail('Process did not terminate within 3 seconds: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $this->assertContains('All jobs finished, exiting.', $proc->getOutput());
 }
All Usage Examples Of Symfony\Component\Process\Process::signal