note 126357 added to function.posix-kill

From: Date: Fri, 20 Aug 2021 17:56:28 +0000
Subject: note 126357 added to function.posix-kill
Groups: php.notes 
Request: Send a blank email to php-notes+get-216816@lists.php.net to get a copy of this message
Although it appears that posix_kill() is built into all modern versions of PHP, it actually requires the "process" extension. Otherwise, you get an "undefined function" error when you call it. You might try this to make your code (more) robust on Linux: <?php function send_signal(int $pid, int $sig_num) : bool { if ( function_exists("posix_kill") ) return posix_kill($pid, $sig_num); exec("/usr/bin/kill -s $sig_num $pid 2>&1", $junk, $return_code); return ! $return_code; } ?> Yes, it works right when $sig_num = 0. ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 108.222.50.143) ---- Manual Page -- https://php.net/manual/en/function.posix-kill.php Edit -- https://main.php.net/note/edit/126357 Del: integrated -- https://main.php.net/note/delete/126357/integrated Del: useless -- https://main.php.net/note/delete/126357/useless Del: bad code -- https://main.php.net/note/delete/126357/bad+code Del: spam -- https://main.php.net/note/delete/126357/spam Del: non-english -- https://main.php.net/note/delete/126357/non-english Del: in docs -- https://main.php.net/note/delete/126357/in+docs Del: other reasons-- https://main.php.net/note/delete/126357 Reject -- https://main.php.net/note/reject/126357 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216816) next »