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

Parent child does not catch signal after forking

I'm having a weird problem in PHP with symfony 1.4 I have a task that launches multiple workers, and, sometimes, I need to stop all the workers (for example, after a deployment). I launch the task using start-stop-daemon, and I want to stop it by…
Talal MAZROUI
  • 645
  • 1
  • 6
  • 12
0
votes
1 answer

cakephp/php run function in background

I've never done this before, so I need some input. Code (in general): $cofig = Configure::read('config'); if ($config['stuff'] == 1){ $this->Session->setFlash('it is already done this month'); $this->redirect('/to/some/where'); …
uldo
  • 19
  • 2
  • 8
0
votes
1 answer

Getting data from forked children

I am playing with pcntl_fork() in PHP. I took the class that is written in the second comment, and tried to send data to it - which seems to work fine. Now I did some processing on that data, and would like to receive some results in my parent…
Vlad Preda
  • 9,780
  • 7
  • 36
  • 63
0
votes
1 answer

how to start a terminated child process from parent in php

I am trying to start a child process from parent when its terminated normally or due to an error.Using pcntl_waitpid, It become possible to get status from child. By that status I want restart the same script or process again. Here is an…
user2764644
  • 11
  • 1
  • 4
0
votes
1 answer

Single Database Connection in forked PHP Application

My application uses pcntl_fork to fork a childprocess which monitors a connected router. So I instantiate the class ConnectionManager which forks themself into as many childprocesses as machines are needed to be monitored. I'm using a external DB…
Ben Matheja
  • 115
  • 2
  • 2
  • 12
0
votes
0 answers

PHP: split work among 5 parallel tasks

I use an external API to gather data for an object. The way the external API is structured, I must make 5 separate calls to different parts of the API in order to get all the data I need. Up to now I've been doing this sequentially, however it takes…
AaplMike
  • 343
  • 1
  • 4
  • 15
0
votes
1 answer

How to start and end new php procces?

I am trying to use a pcntl extetntion for PHP to run some methods of my CLI class in a new thread. I wrote a small test method: private function startProcess($data) { $this->log('Start a child process'); $pid = pcntl_fork(); if($pid ==…
Kin
  • 4,466
  • 13
  • 54
  • 106
0
votes
1 answer

PHP forking tool produce zombie process

I am new on PHP forking and I just copy this code sample from PHP.net. Basically I have a tool that monitor a device and save the data into a database. This tool is running in background. here is my code: for(;;) { //build connection $conn =…
0
votes
1 answer

Is incoming signals crashes blocking on a stream in php application

I used pcntl extension in my code like this : I bind a handler to some signal, for example SIGUSR1, and have a script which send signals to my application. pcntl_signal(SIGUSR1, function ($signo){ echo 'Signal:' . $signo . PHP_EOL; }); And I have…
Stanislav
  • 33
  • 6
0
votes
1 answer

Php forking and memory sharing drive me nuts

I have passed hours and days to find why php share the memory between my forked children and I figured that if the parent set a var in a function before forking then the function will always return the same result in the children :~ new…
beunwa
  • 104
  • 2
0
votes
0 answers

how to join forked processes in php

where in I need to fork a process. Then when their task completes, the parent process should go ahead and do some other work. How can this be done? Here's what I have done $sql = "call some_sample_proc()"; $res =…
Shades88
  • 7,934
  • 22
  • 88
  • 130
0
votes
1 answer

PHP pcntl_fork() : lose code in browser

I'd like to implement bigpipe in PHP using pcntl. However, there is something wrong when I visit the web page from browser. test.php