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

what is the difference between pcntl_exec and exec in php?

I've read the docs at http://us1.php.net/manual/en/function.pcntl-exec.php and http://php.net/manual/en/function.exec.php but I can't really tell what the actual difference is.
6
votes
1 answer

What's a "good" setting for PHP ticks with pcntl_signal?

I'm running a PHP daemon with a signal handler to do an orderly cleanup and to reconfigure without stopping: declare(ticks = 5); function sig_handler($signo) { ... } pcntl_signal(SIGHUP, 'sig_handler'); pcntl_signal(SIGINT,…
Matt S
  • 14,976
  • 6
  • 57
  • 76
6
votes
2 answers

What are the best/popular libraries for developing CLI apps/scripts?

Many of the component libraries and toolkits I'm familiar with lack CLI-specific libraries (zend, kohana, etc..). Are there any libraries/tools that are designed specifically for developing CLI application (such as an abstraction of php's…
John Himmelman
  • 21,504
  • 22
  • 65
  • 80
6
votes
4 answers

How to check PCNTL module exists

I write simple requirements checking script. It checks all required PHP modules installed. I need to check if pcntl is installed. But this module is accessible only in cgi environment and invisible for web queries. extension_loaded('pcntl') and…
WindBridges
  • 693
  • 2
  • 11
  • 23
6
votes
2 answers

Why does pcntl_fork() copy PHP objects?

The manual for pcntl_fork() says: The pcntl_fork() function creates a child process that differs from the parent process only in its PID and PPID. However, running this simple test surprised me: class Foo { public function bar() { …
BenMorel
  • 34,448
  • 50
  • 182
  • 322
5
votes
3 answers

How do I keep my mysql connection in the parent process after pcntl_fork?

As all of you know when you fork the child gets a copy of everything, including file and network descriptors - man fork. In PHP, when you use pcntl_fork all of your connections created with mysql_connect are copied and this is somewhat of a problem…
doycho
  • 53
  • 1
  • 5
5
votes
1 answer

Process signal handlers are not called

I'm working on a pre-forking TCP socket server written in PHP. The daemon (the parent process), forks some number of children and then waits until it's told to exit and the children are all gone or it receives a signal. SIGINT and SIGTERM cause it…
David Patterson
  • 1,780
  • 3
  • 17
  • 40
5
votes
0 answers

PHP Readline: Get a new prompt on SIGINT

I'm writing a php cli interactive program, it act as a shell by using readline extension. But I find that when I press Ctrl + C, the whole program exits. I hope it can get a new prompt instead of exit (just like bash). So I try pcntl_signal to…
leo108
  • 817
  • 5
  • 12
5
votes
1 answer

PHP PCNTL - what does pcntl_signal()'s restart_syscalls parameter do?

I've been using PHP's PCNTL extension for a little while now, but can't figure out what the restart_syscalls parameter of pcntl_signal() does. I tried looking around the Internets, but couldn't find any information. All the documentation says…
Marco Roy
  • 4,004
  • 7
  • 34
  • 50
5
votes
1 answer

PHP sleep, pcntl_signal, and ticks

Ok, so I've been trying to get Process Signals to work with PHP scripts. I've run into a lot of stuff where I am just not sure what is going on, and I feel like the documentation doesn't do a very good job of explaining it. So let's say I follow the…
MirroredFate
  • 12,396
  • 14
  • 68
  • 100
5
votes
2 answers

pcntl_wait not interrupted by SIGTERM

According to the PHP docs for pcntl_wait, The wait function suspends execution of the current process until a child has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling…
ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
4
votes
1 answer

pcntl_async_signals() has been disabled for security reasons || Ubuntu 16 - Laravel 5.6

I have a server running on Ubuntu 16.04 running Laravel app version 5.6.29 on PHP version 7.2.8. I have set up some queue jobs to upload videos to the server and compile them and upload to s3 bucket. Suddenly from the past few hours,I am facing the…
JItendra Rana
  • 141
  • 1
  • 9
4
votes
1 answer

Unable to find pcntl on homebrew in mac high sierra

I have been trying to install pcntl extension using homebrew in MacOS High sierra using command brew install homebrew/php/php71-pcntl brew install homebrew-php/php71-pcntl Also tried with php54, 55, 56, 70 I m getting error Updating…
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
4
votes
1 answer

How to install PHP extension 'pcntl' on my Mac OSX without brew

So, I'm trying to install the pcntl extension on my MacBook Pro (High Sierra 10.13.4). I tried following the guides that I can find online, but they are all outdated, since Homebrew decided to move all php packages to their core, and delete some of…
Emmezali
  • 43
  • 1
  • 7
4
votes
3 answers

Why is not a good idea to use multithreading in php?

I know php doesn't have threading. But in this tutorial they show that by using host operating systems ability to form we can achieve it. It has also said it to not do this in the production code. Why is it not a good idea? Here is a sample…
odbhut.shei.chhele
  • 5,834
  • 16
  • 69
  • 109
1
2
3
11 12