Voting

: four plus five?
(Example: nine)

The Note You're Voting On

corychristison at lavacube dot com
21 years ago
An easier way than what was first suggested in the first comment, to retrieve what signal your application is being sent would be to use get_defined_constants() to list all constants, loop through and strip out those that are not signals, and to check if it matches the value.

Here is my code for doing this, written for PHP5 only.
<?php

// php5 Specfic

function pcntl_sig_identify ( $sig_no ) {
    $get_constants = get_defined_constants(true);
    $pcntl_contstants = $get_constants["pcntl"];
    $keys = array_keys( $pcntl_contstants );
      foreach($keys as $key){
        if(strstr($key, "SIG") && !strstr($key, "_") && $pcntl_contstants[$key] == $sig_no){
      return $key;
    }
      } // end loop
} // end function pcntl_sig_identify

// 
// This example will output "SIGTERM"
//

print pcntl_sig_identify(15) . "\n";

?>

<< Back to user notes page

To Top