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
1
vote
2 answers

Why is the use of pcntl library in php is discouraged on prod-serv?

Can anybody tell me why using the pcntl lib on production servers is discouraged? The PHP manual tells very briefly about it, and I'm in a dire need to use this library... Is there another way to do the same thing in php?
marek
  • 259
  • 8
  • 19
1
vote
1 answer

Symfony3 Command - pcntl doesn't works

I want to stop executing my command from controller action so I tried to use pcntl to achieve this. This is my code(Command): protected $should_stop = false; protected function execute(InputInterface $input, OutputInterface $output) { …
SakuragiRokurota
  • 185
  • 1
  • 3
  • 12
1
vote
1 answer

Unexpected cores synchronization in pcntl_fork()

I'm researching multi-core optimization abilities in PHP. My test program forks 4 processes so that each one should run twice as long as previous. Code is: $iters = 20000000; for ($c = 0; $c < 4; $c++) { $pid = pcntl_fork(); if ($pid…
Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70
1
vote
0 answers

Call to undefined function pcntl_wifsignaled()

I'm attempting to use the import functionality in mediawiki 1.27.0, but I'm getting the error message: Call to undefined function pcntl_wifsignaled() in extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 645 I'm running PHP…
Ben
  • 427
  • 5
  • 17
1
vote
1 answer

php pcntl_alarm - pcntl_signal handler doesn't fire?

I'm considering using pcntl_alarm() for something, so to test it out I ran a variation of the example you find everywhere when you google pcntl_alarm: function signal_handler() { echo "Caught SIGALRM\n"; exit; } pcntl_signal('SIGALRM',…
Mark H.
  • 549
  • 6
  • 16
1
vote
1 answer

kill is absorbed by "system" call and never triggers pcntl_signal

I have a daemon script and I'm trying to keep it simple by avoiding threads. When i ctrl-c or kill pid, the "system" call is exited, but exitFunction isn't called. declare(ticks = 100); function exitFunction($signo) { global $pidFile, $exit; …
Sophie McCarrell
  • 2,831
  • 8
  • 31
  • 64
1
vote
0 answers

Child process in php executes destructor of class objects created in parent process

In the below code. I am trying to understand the behavior. class ForkManager { private $_max_workers = 3; private $_open_processes = 0; private $_tasks = array(); public function setMaxWorkers($num) { …
jimy
  • 4,848
  • 3
  • 35
  • 52
1
vote
0 answers

Commands return exit code 2 while process is terminating

I have a long-running PHP process which is handling signals. The signals are handled at the end of each "iteration" using pcntl_signal_dispatch(), along with some other tasks. Some of these tasks run command line operations, such as find. As soon as…
Marco Roy
  • 4,004
  • 7
  • 34
  • 50
1
vote
0 answers

How to view process output with PID ? (proc_open)

edited: goal: I have an application written in Python that can download videos from web pages! (auto detect video link in youtube or other video site) When I run it in CMD , Runs well and shows the download speed and remined time. Now I want to make…
PersianMan
  • 924
  • 1
  • 12
  • 29
1
vote
3 answers

Looping or Recursive PHP Function on time delay - Need Event Loop? Forking?

I have a PHP function that needs to be executed ~10 seconds after certain events. The Function can in turn create a new instance of the event, which would need to trigger the function again ~10 seconds later. Often the function won't create a new…
Charles
  • 853
  • 3
  • 8
  • 21
1
vote
1 answer

Parallel processing in PHP using zeroMQ

Some background: I am building a server application in php that will need to execute a number of independent tasks on a user request. Theres is a severe requirement on speed for my application so I would like to execute all of those tasks in…
roinir
  • 300
  • 2
  • 9
1
vote
0 answers

How to pass data from child process to master process by php pcntl?

I start some pcntl process to calculate some data, and I want to wait all child process end ,and send all return data to master process. How Can I do that? my pnctl trait like that:
jianfeng
  • 2,440
  • 4
  • 21
  • 28
1
vote
1 answer

Wrong exit code received from wexitstatus

I'm using PCNTL to multiprocess a big script in PHP on an ubuntu server. Here is the code ( simplified and commented ) function signalHandler($signo = null) { $pid = posix_getpid(); switch ($signo) { case SIGTERM: case…
Random
  • 3,158
  • 1
  • 15
  • 25
1
vote
2 answers

php signal not handled right away

I have a software written in PHP which can run for a long time, it's lauched via command line (not a web application). I wanted to make sure to call a function when the software exit, including when killed via ctrl+c. When killed by a signal, the…