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
4
votes
1 answer

After php upgrade pcntl_fork causing "errno=32 Broken pipe"

I recently upgraded from php 5.4.26 to 5.4.28 after the upgrade I am getting this error Notice: Unknown: send of 6 bytes failed with errno=32 Broken pipe in Unknown on line 0 When ever I run the following code:
Alistair Prestidge
  • 673
  • 3
  • 9
  • 19
4
votes
1 answer

Right strategy with shared memory and semaphore removing in RAII like php class

When such situation occurs? If your are using shared memory and semaphores for interpocess locking (with pcntl extension) you should care about semaphore and shared memory segment life circle. For example, you writing backgroud worker application…
Nick Bondarenko
  • 6,211
  • 4
  • 35
  • 56
4
votes
1 answer

PHP pcntl module install

I'm about to start working with yii framework using composer and for that I need this php pcntl module working. As I read from the manuals it is not installed in ubuntu by default. Because of that I've found some instructions something like…
David
  • 4,332
  • 13
  • 54
  • 93
4
votes
1 answer

pcntl runs the same code several times, assistance required

I am using pcntl in order to speed up a quite heave CLI php script, that consists mostly of a class, that is in charge of sending all of the auto-emailing on my application. My goal is as following: I want to assign each process to a certain task,…
Oleg Belousov
  • 9,981
  • 14
  • 72
  • 127
4
votes
2 answers

how can i call two api's together at same time without waiting for response from first?

I am making a search widget. when i am searching i am taking results from 2 api's one is from yelp and other is from another source. but this process is taking a longer time $dataProvider = SearchUtil::locallookup($for, $near); //local…
Mahesh Eu
  • 515
  • 1
  • 6
  • 21
4
votes
1 answer

pcntl_sigwaitinfo and signal handlers

I'm writing a daemon which periodcally does some work and sleeps some time before repeating it again. But it must still be responsive to outer impacts (i.e. termination request) while asleep. I managed to implement sleep timeout with ALRM signal and…
Kaero
  • 43
  • 3
4
votes
3 answers

PHP pcntl_signal callbacks are not called

This is the complete reproducible code.
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
4
votes
2 answers

how to use pcntl_fork() with Apache?

This is my code, inside index.php (just an example): $pid = pcntl_fork(); if ($pid == -1) { die("failed to fork"); } else if ($pid) { // nothing to do } else { putDataIntoWebService(); exit(); } echo "normal page content"; This snippet…
yegor256
  • 102,010
  • 123
  • 446
  • 597
4
votes
1 answer

How to interrupt exec and kill child processes

I'm trying to invoke a long-running shell command inside a PHP CLI script with exec(). But I can't for the life of me figure out how to interrupt the PHP script and kill the spawned child process(s). It seems like as soon as I call exec(), my signal…
ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
3
votes
2 answers

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
  • 13,367
  • 3
  • 42
  • 49
3
votes
3 answers

activate pcntl_fork() ubuntu xampp

I'm having some problems with the function pcntl_fork() in php. I'm using XAMPP and I'm trying to use that function and keeps me showing this error: Call to undefined function pcntl_fork() I dig something on Google and in XAMPP forums but…
Elkas
  • 603
  • 12
  • 27
3
votes
2 answers

How do I use $status returned by pcntl_waitpid()?

I have a parent/worker arrangement going on. The parent keeps the worker PIDs in an array, constantly checking that they are still alive with the following loop: // $workers is an array of PIDs foreach ($workers as $workerID => $pid) { // Check…
Drew Stephens
  • 17,207
  • 15
  • 66
  • 82
3
votes
1 answer

How to install pcntl extension on ubuntu 15

I am trying to install pcntl on ubuntu 15 and i get this while trying to get php5 source. The procedure that I am fallowing is sudo apt-get source php5 cd php5(release version)/ext/pcntl sudo phpize sudo ./configure sudo make sudo make install But…
andy1786
  • 121
  • 4
  • 13
3
votes
2 answers

Process respawn and signal handling in PHP

Specifics I have an issue in PHP, when respawned processes are not handling signals, while before respawning, handling working correctly. I narrowed down my code to the very basic: declare(ticks=1); register_shutdown_function(function() { if…
Alma Do
  • 37,009
  • 9
  • 76
  • 105
3
votes
1 answer

Best way to offload one-shot worker threads in PHP? pthreads? fcntl?

How should I multithread some php-cli code that needs a timeout? I'm using PHP 5.6 on Centos 6.6 from the command line. I'm not very familiar with multithreading terminology or code. I'll simplify the code here but it is 100% representative of what…
Finlay Beaton
  • 601
  • 6
  • 15
1 2
3
11 12