Esempio n. 1
0
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testKillChildrenSigKill()
 {
     $loopEcho = function () {
         while (true) {
             usleep(50 * 1000);
             echo "hello\n";
         }
     };
     $loopEchoStayinAlive = function () {
         pcntl_signal(SIGTERM, function () {
             echo "Well, you can tell by the way I use my walk\n I'm a woman's man, no time to talk\n";
         }, false);
         while (true) {
             usleep(50 * 1000);
             echo "hello\n";
         }
     };
     $process = CM_Process::getInstance();
     $process->fork($loopEcho);
     $process->fork($loopEchoStayinAlive);
     $pidListBefore = $this->_getChildrenPidList();
     $timeStart = microtime(true);
     $process->killChildren(0.5);
     $this->assertCount(2, $pidListBefore);
     $this->assertCount(0, $this->_getChildrenPidList());
     $this->assertSameTime(0.5, microtime(true) - $timeStart, 0.15);
     $logError = new CM_Paging_Log_Error();
     $this->assertSame(1, $logError->getCount());
     $this->assertContains('killing with signal `9`', $logError->getItem(0)['msg']);
 }