Skip to main content
The 2024 Developer Survey results are live! See the results

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.

pcntl
0 votes
0 answers
35 views

pcntl_fork: parent process stops after child process exits

When the child process created by pcntl_fork() runs exit(0) also the parent process ends. I say end and not exist, because I see a strange behavior: the request ends with an empty output (with HTTP ...
Mattia Consiglio's user avatar
0 votes
0 answers
42 views

Why does ignoring SIGCHLD cause exit code -1?

This code expectedly outputs "0": exec('date', $output, $resultCode); echo $resultCode . PHP_EOL; However, if I prepend this line: pcntl_signal(SIGCHLD, SIG_IGN); then the output is "-...
Greendrake's user avatar
  • 3,714
0 votes
0 answers
180 views

pcntl-fork equivalent with php-fpm

I have recently migrated one of my php applications from hostgator to AWS using the Apache AMI. The PHP is running with the server API as FMP/FastCGI, my code is currently built for CGI/FastCGI. With ...
FutureShock's user avatar
1 vote
0 answers
238 views

change loop uses pcntl_fork by fiber in php 8.1

Can someone help me please, to use fiber on a loop like pcntl_fork to process data in parallel, Here is the code for converting to fiber, Thanks. `$names = array('A','B','C','D','E'); $childs = array()...
david david's user avatar
0 votes
0 answers
214 views

usleep() in while loop causing issues - whole process freezes

I am using php, Laravel, Redis, and SQL on an Ubuntu localhost server. I have made a bunch of methods that return results from API searches after some processing. I am calling 5 of these methods which ...
joshuasy10's user avatar
0 votes
0 answers
626 views

Install/enable PHP 7.4 PCNTL extenstion on Ubuntu 20

I am trying to run php7.4 code as async using package spatie/async but seems to have problem with PCNTL extension. I have followed this to install pcntl extenstion but have error on step:7 Not sure ...
Hemant Kumar's user avatar
  • 1,105
2 votes
0 answers
2k views

Enable PHP8.1 extension PCNTL on Ubuntu 22.04 and Docker

I am trying to enable the PCNTL extension for PHP 8.1 on Ubuntu 22.04 but have been unsuccessful. When I run a command php -i | grep pcntl via terminal it returns pcntl support => enabled but the ...
PYovchevski's user avatar
3 votes
2 answers
764 views

Why doesn't PHP pcntl_fork run more than two child processes in parallel?

I understand how fork() works at a high level and the pcntl_fork() wrapper, but for some reason in my environment PHP only runs two child processes at a time. Take for example this simple code: <?...
ColinM's user avatar
  • 13.8k
0 votes
1 answer
472 views

pcntl_fork not working when being used with apache but does work from CLI

I have a small mission critical web app that needs to respond to all requests rather fast. I need to run some other code that can potentially take a few seconds. I was trying to use pcntl_fork. If I ...
Dovid Bender's user avatar
0 votes
0 answers
51 views

Why do a variable gets overridden in some threads?

I am getting a variable overridden some times(Each time I run the script I get different result) in other threads, or if I split the total threads to run in chunks. Would you explain to me what does ...
H Aßdøµ's user avatar
  • 3,025
0 votes
1 answer
259 views

Is there a way to signal a SIGALRM with a finer-grained delay than pcntl_alarm(int $seconds)?

pcntl_alarm(int $seconds) only has a resolution of seconds. Is there a way in PHP to signal a SIGALRM with a delay of, say, milliseconds? Maybe a posix_kill() with a delay argument? PS.: I'm aware of ...
Decent Dabbler's user avatar
1 vote
1 answer
156 views

PHP: proc_get_status exitcode is always -1 after pcntl_fork

I'm having troubles with using proc_get_status after a pcntl_fork in the parent process. Here's an example with docker and PHP 7.4, but note the PHP version does not matter, the result is the same ...
ymarillet's user avatar
0 votes
1 answer
118 views

PHP class loaded by child process becomes visible in parent process?

I am trying to add a mechanism for loading classes on demand and then basically unloaded them / being able to reload them. Essentially, each time the class is needed, it should be loaded freshly from ...
InterLinked's user avatar
  • 1,374
0 votes
0 answers
102 views

Yii2 redirect and pcntl_fork

Using Yii2 I have implemented pcntl_fork() in one of my controllers and though the process is working as I need there are a few issues I would like to sort out. Simplified logic //Start timer marker ...
Scott Johnson's user avatar
1 vote
1 answer
475 views

Handle process signals in Swoole script without pcntl_signal() function

I'm implementing a php parallel tasks script based on Swoole module which works as daemon. Is it possible to use Swoole functions to handle process signals instead of pcntl_signal()? <?php declare(...
Andrey Lebedev's user avatar

15 30 50 per page
1
2 3 4 5
12