PHP exec unable to fork problem

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
joey2017
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Oct 20, 2017 4:13 am

Fri Oct 20, 2017 4:41 am

Hi,

Im having a problem with PHP where im trying to run commands for an embedded linux target. The code executes / works but after extended use im seeing the available memory drop and then loss of exec() functionality with the error_log reporting PHP Warning: exec(): Unable to fork [sudo /usr/bin/whoami........]

Apache is still serving web pages for clients and the mysql DB is still active. Restarting the Apache services restores exec() functionality. Ive tried websockets and this problem still occurs.

Im running PHP 5.6.31, Apache 2.4.27

The code im trying to run from a web browser is as follows..

Code: Select all

<?php
	exec("sudo /usr/bin/whoami", $outputArr, $returnVal);
	echo "returnVal(" . $returnVal . ") outputArr(" . implode("", $outputArr) . ")";
?>
Can anyone help please...

Thanking you in advance

J

Post Reply