note 47103 added to ref.pcntl

From: Date: Wed, 03 Nov 2004 02:53:46 +0000
Subject: note 47103 added to ref.pcntl
Groups: php.notes 
Request: Send a blank email to php-notes+get-79531@lists.php.net to get a copy of this message
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"; ?> ---- Manual Page -- http://www.php.net/manual/en/ref.pcntl.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47103 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47103&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47103&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#79531) next »