Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pcntl_fork() returning, Fatal error: Call to undefined function pcntl_fork()

Tags:

I'm trying to fork a command line run XAMPP php process using pcntl_fork(). When I run the command below:

$pid = pcntl_fork(); if($pid == -1){     file_put_contents('testlog.log',"\r\nFork Test",FILE_APPEND);     return 1; //error } else if($pid){     return 0; //success } else{        file_put_contents($log, 'Running...', FILE_APPEND); } 

I get:

Fatal error: Call to undefined function pcntl_fork() 

Can anyone suggest how to fix this?

like image 687
Ben Pearce Avatar asked May 30 '13 01:05

Ben Pearce


1 Answers

It is not possible to use the function 'pcntl_fork' when PHP is used as Apache module (such as XAMPP). You can only use pcntl_fork in CGI mode or from command-line.

Using this function will result in: 'Fatal error: Call to undefined function: pcntl_fork()'

Source: http://php.net/manual/en/function.pcntl-fork.php

like image 164
Andrea Avatar answered Sep 23 '22 05:09

Andrea