* Signal dispatch() method now uses own pid as default value * SharedData now updates checksum cache on set()
		
			
				
	
	
		
			29 lines
		
	
	
		
			790 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			790 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
require_once __DIR__."/../vendor/autoload.php";
 | 
						|
 | 
						|
use NoccyLabs\Ipc\Signal\SignalHandler;
 | 
						|
use NoccyLabs\Ipc\Signal\Signal;
 | 
						|
 | 
						|
 | 
						|
$handler = new SignalHandler(SIGUSR1);
 | 
						|
 | 
						|
// Add handlers like this, or as an array passed as the second argument to the constructor
 | 
						|
$handler->addHandler(function () {
 | 
						|
    echo "First handler\n";
 | 
						|
});
 | 
						|
// If a handler returns true, it will prevent any further handlers from firing
 | 
						|
$handler->addHandler(function () {
 | 
						|
    echo "Second and final handler\n";
 | 
						|
    return true;
 | 
						|
});
 | 
						|
// Thus, this one will not be called
 | 
						|
$handler->addHandler(function() {
 | 
						|
    echo "Third handler, never called\n";
 | 
						|
});
 | 
						|
 | 
						|
// Dispatch the signal to ourselves
 | 
						|
(new Signal(SIGUSR1))->dispatch(posix_getpid());
 | 
						|
// Default target of dispatch is the own pid
 | 
						|
(new Signal(SIGUSR1))->dispatch();
 | 
						|
    
 |