PHP proc_open will not work - gives me "Missing handle descriptor in array"

Warning: proc_open (): Missing handle specifier in array in C: \ ... \ updatedots.php on line 102

I try to open a notebook by closing it after 2 seconds. This is my code:

$descriptorspec = array( 0 => array("pipe" => "r"), 1 => array("pipe" => "w"), 2 => array("file" => "logs/errors.txt") ); // Create child and start process $child = array("process" => null, "pipes" => array()); $child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]); 

Any idea what this error means and what causes it?

+6
source share
1 answer

It is not 0 => array("pipe" => "r") , but 0 => array("pipe", "r") ^^

In addition, when specifying the file name, you must specify the mode used. This works on my machine:

 $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "logs/errors.txt", "a") ); // Create child and start process $child = array("process" => null, "pipes" => null); $child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]); 
+8
source

Source: https://habr.com/ru/post/888421/


All Articles