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

171 questions
3
votes
1 answer

pcntl_signal function not being hit and CTRL+C doesn't work when using sockets

I have a simple PHP script that I want to run from the terminal, and be able to process signal codes. The script creates a TCP server and processes connections. Not sure why, but I can't get signal processing to work:
donutdan4114
  • 1,262
  • 1
  • 8
  • 16
3
votes
1 answer

How does PHP handle two processes with the same exclusive lock?

It appears that when php uses flock() to acquire an exclusive lock to a file, and then uses pcntl_fork to split into two processes, both processes have the same exclusive lock - that is to say, further calls to flock($fd, LOCK_EX) on that file…
Benubird
  • 18,551
  • 27
  • 90
  • 141
3
votes
0 answers

pcntl_signal callbacks set on object method

I've been trying to set SIGTERM handler on object method, but I discovered something I don't understand. Let's consider the following code: function _log($msg, $arr=array()){ $str = vsprintf($msg, $arr); fprintf(STDERR, "$str\n"); } class…
3
votes
0 answers

pcntl_fork() usage in PHPUnit tests

I have some problem with pcntl_fork() usage in PHPUnit. I'm executing this code class ForkTest extends PHPUnit_Framework_TestCase { public function test1() { print('Start test with pid '.posix_getpid()."\n"); $pids = []; …
mifril
  • 31
  • 2
3
votes
1 answer

PCNTL for MAMP with php5.4.4. and OSX 10.8

All of the instructions I find on the internet are for older versions of phpize, MAMP, php and OSX. I've tried following the instructions at: using php5.4.4 and OSX 10.8 and yet I keep getting this issue: [27-Feb-2013 17:46:17 UTC] PHP Warning: PHP…
2
votes
2 answers

how to solve laravel/horizon v4.3.3 requires ext-pcntl problem

I'm using Windows operating system. I've also tried with these solutions available here: link 1) PHP pcntl module installation link 2) How to install PCNTL extension in Windows? ./composer.json has been updated Loading composer repositories with…
2
votes
1 answer

Connection errors in forked PHP processes

I have a PHP script that takes N documents from MongoDB, forks the process into K child PHP processes, each process does some things with each document and tries to update document's info (see the code below). On my local environment (Docker)…
2
votes
1 answer

Why pcntl_fork() not defined in Laravel Controller?

I have Controller: class HomeController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct(){} public function index() { pcntl_fork(); …
Sayakiss
  • 6,878
  • 8
  • 61
  • 107
2
votes
2 answers

What are the side-effects of enabling PROCESS CONTROL (PCNTL) in PHP on web server environment?

below is a quotation from http://www.php.net/manual/en/intro.pcntl.php Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server…
Lina
  • 2,090
  • 4
  • 20
  • 23
2
votes
2 answers

Module pcntl already loaded in Unknown on line 0 - Apache x Cli

I'm getting this PHP Warning: Module 'pcntl' already loaded in Unknown on line 0 But it is only enabled for Apache. Enabled it on /etc/php/7.2/apache2/conf.d/20-pcntl.ini: extension=pcntl.so I don't have it enabled on CLI. Checked with: I don't…
Bivis
  • 1,320
  • 1
  • 10
  • 24
2
votes
1 answer

pcntl_wifexited always return true

Well the child process may exit with error but pcntl_wifexited always return true
DEY
  • 1,770
  • 2
  • 16
  • 14
2
votes
2 answers

Long PHP SOAP process

I've been working on a website that get all its data through SOAP. Some pages may have three or four calls to the soap server and some of the calls can sometimes take quite long (30-60 seconds). What I've noticed happening is if I interrupt the…
Nick
  • 229
  • 5
  • 12
2
votes
3 answers

pcntl_fork() function

Because crawling the web can cost a lot of time I want to let pcntl_fork() help me in creating multiple childs to split my code in parts. Master - crawling the domain Child - When receiving a link child must crawl the link found on the domain Child…
user443346
2
votes
2 answers

Improving HTML scraper efficiency with pcntl_fork()

With the help from two previous questions, I now have a working HTML scraper that feeds product information into a database. What I am now trying to do is improve efficiently by wrapping my brain around with getting my scraper working with…
Michael Pasqualone
  • 2,027
  • 2
  • 15
  • 23
2
votes
1 answer

pcntl_signal signal not received

I'm having some problems with pcntl_signal not receiving a signal sent from another process. I have a script that forks a new process, fires up 2 background threads and then loops the controller (main) thread until it receives a stop signal…
JWood
  • 2,804
  • 2
  • 39
  • 64