Search code examples
phpubuntu-serverpcntl

Undefined pcntl_signal_dispatch() with pcntl installed


I'm having touble using pcntl on an ubuntu server VM.
I have a PHP script making threads to do repetitive stuff.
My server has the pcntl extention for PHP.

Using command php -me output this :

calendar
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mbstring
mysql
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
shmop
SimpleXML
SPL
SQLite
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

I added logs in the code so I'm sure pcntl_fork, pcntl_wait and pcntl_wexitstatus are executed by the script.
But on the line using pcntl_signal_dispatch(), it crashed with the error :

Call to undefined function pcntl_signal_dispatch()

Any clue is welcome :)


Solution

  • Unlike most (if not all) of the PCNTL functions,pcntl_signal_dispatch() requires PHP 5.3 or newer: http://php.net/pcntl_signal_dispatch

    So you're either running a really old PHP version, or the function is disabled in php.ini, but my guess would be the former.