note 108873 modified in function.pcntl-signal by thiago

From: Date: Thu, 31 May 2012 15:30:10 +0000
Subject: note 108873 modified in function.pcntl-signal by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188333@lists.php.net to get a copy of this message
static class method to get the name of a process signal as string:

(self::$processSignalDescriptions is used to cache the results)

<?php
 public static function getPOSIXSignalText($signo) {

 try {
 if (is_null(self::$processSignalDescriptions)) {

 self::$processSignalDescriptions = array();

 $signal_list = explode(" ", trim(shell_exec("kill -l")));
 foreach ($signal_list as $key => $value) {
 self::$processSignalDescriptions[$key+1] = "SIG".$value;
 }
 }

 return isset(self::$processSignalDescriptions[$signo])?self::$processSignalDescriptions[$signo]:"UNKNOWN";

 } catch (Exception $e) {}

 return "UNKNOWN";
 }
?> --was-- static class method to get the name of a process signal as string: (self::$processSignalDescriptions is used to cache the results) public static function getPOSIXSignalText($signo) { try { if (is_null(self::$processSignalDescriptions)) { self::$processSignalDescriptions = array(); $signal_list = explode(" ", trim(shell_exec("kill -l"))); foreach ($signal_list as $key => $value) { self::$processSignalDescriptions[$key+1] = "SIG".$value; } } return isset(self::$processSignalDescriptions[$signo])?self::$processSignalDescriptions[$signo]:"UNKNOWN"; } catch (Exception $e) {} return "UNKNOWN"; } http://php.net/manual/en/function.pcntl-signal.php

« previous php.notes (#188333) next »