Questions tagged [pcntl]

PCNTL is short for Process Control, a PHP Extension implementing the Unix style of process creation, program execution, signal handling and process termination.

Documentation of the PHP PCNTL extension can be found here: https://php.net/pcntl

157 questions
31
votes
6 answers

how to enable process control extension (PCNTL) in PHP MAMP?

I have MAMP and I need to enable -pcntl on my current MAMP installation. How can I do so? Thanks for your help.
Lina
  • 2,010
  • 4
  • 19
  • 23
24
votes
1 answer

How does pcntl_fork work in PHP?

I'm confused about pcntl_fork in PHP. I think it does multi-threading, but how does it work and how would I use it in a script?
user1432856
  • 333
  • 1
  • 3
  • 6
22
votes
4 answers

pcntl_fork() returning, Fatal error: Call to undefined function pcntl_fork()

I'm trying to fork a command line run XAMPP php process using pcntl_fork(). When I run the command below: $pid = pcntl_fork(); if($pid == -1){ file_put_contents('testlog.log',"\r\nFork Test",FILE_APPEND); return 1; //error } else if($pid){ …
Ben Pearce
  • 6,162
  • 16
  • 64
  • 122
22
votes
2 answers

pcntl not working on Ubuntu 'for security reasons'

I have installed pcntl on my PHP 5.4.6 running on Ubuntu 32-bit 12.10, using this article. It didn't go smoothly at all because after compiling, when running make test I got the following errors. I am getting a warning each time that I'm trying to…
Oleg Belousov
  • 9,633
  • 12
  • 68
  • 119
17
votes
2 answers

Can I rely on register_shutdown_function() being called on SIGTERM, if pcntl_signal() is set up?

I am working on an application that has periodically-called background processes. One of these was being called by cron, but I am looking for something more robust, so am converting it to run under Supervisor. (It will probably run for 10 minutes,…
halfer
  • 18,701
  • 13
  • 79
  • 158
16
votes
2 answers

How to install PCNTL extension in Windows?

I am running PHPUnit in Windows and trying to install PHPUnit via composer.json: "phpunit/php-invoker": "*" ...with this dependency, but I am getting this error: phpunit/php-invoker 1.1.3 requires ext-pcntl * -> the requested PHP extension pcntl…
Yogesh
  • 597
  • 2
  • 5
  • 18
11
votes
3 answers

PHP CLI in Windows: Handling Ctrl-C commands?

How can I handle CTRL+C in PHP on the command line? Pcntl_* functions do not work in Windows.
x74x61
  • 403
  • 6
  • 18
11
votes
5 answers

Enable PCNTL in Ubuntu PHP - test fails

I need help on How to: Enable PCNTL in Ubuntu PHP. $ mkdir /tmp/phpsource $ cd /tmp/phpsource $ wget http://museum.php.net/php5/php-5.3.2.tar.gz $ tar xvf php-5.3.2.tar.gz $ cd php-5.3.2/ext/pcntl $ phpize -bash: phpize: command not…
Folding Circles
  • 414
  • 2
  • 5
  • 13
9
votes
3 answers

killing zombie children in parent processes

So I want to do the following: Set up a daemon that forks a bunch of processes. So the Daemon forks a bunch of processes then forks another bunch of processes the problem is the child processes might take a long time to exit. How do I prevent zombie…
user816604
9
votes
1 answer

Call to undefined function pcntl_fork() php-fpm nginx

I'm trying to use pcntl_fork() in php-fpm but it is not available and I get: Call to undefined function pcntl_fork() Even though I've out-commented the disable_functions in the php.ini. phpinfo() shows the author and php -m also lists pcntl. If I'm…
white_gecko
  • 3,919
  • 3
  • 42
  • 66
9
votes
1 answer

What's the relation between declare(ticks) and a signal handler in php

I have some code like this, and I want to understand how does fork work, but I'm confused with declare(ticks=1). when I put it in the first line, after the child process finished, the signal handler will be called, which is what I want; but when I…
zhaozhi
  • 1,273
  • 1
  • 12
  • 19
8
votes
1 answer

Subsequent pcntl_signal signals not kicking off handler

Lemme begin by giving a basic description of the code I have. I start off with a main parent process (NOTE: I am not showing all functions for simplicity. Let me know if you need me to expand at any point): declare(ticks=1); pcntl_signal(SIGHUP,…
Aram Papazian
  • 2,161
  • 6
  • 32
  • 43
7
votes
2 answers

How to install PHP extension 'pcntl' on my Mac OSX

My operating system is:Mac OSX 10.11 I'm trying to install Phabricator on my Mac, when I execute the command of phabricator cpopt$ ./bin/phd start I got an error: "ERROR: The PHP extension 'pcntl' is not installed. You must install it to run…
Maker
  • 93
  • 1
  • 1
  • 7
6
votes
1 answer

posix_kill vs pcntl_signal

This is a bit esoteric and it's possible this question will go unanswered until I troll the the source myself and answer it, but here goes: I'm the author of a simple PHP Daemon library: https://github.com/shaneharter/PHP-Daemon. While PHP isn't…
Shane H
  • 3,103
  • 5
  • 24
  • 28
6
votes
2 answers

How can I check a PDO MySQL connection for errors BEFORE I run a query?

My scripts are getting quite riddled with forked processes in a lot of different functions. Whenever pcntl_fork() is called, all MySQL connections are lost. If I run a query on a PDO MySQL connection I get the error "MySQL server has gone away". The…
Hubro
  • 48,322
  • 60
  • 196
  • 344
1
2 3
10 11