I'm revisiting why I'm running into situation where at random times ( perhaps 1% of the time ) the PHP script I use to encrypt my XML on the fly will error and deliver an exit code of 1, resulting in an xml error in the KRPano viewer..
The error happens leveraging system(), exec() and proc_open().
The current method, proc_open() either produces an exit code of 0 ( normal exit) or 1, never -1.
With proc_open() I'm able to capture the two output streams. The output [1] (the encrypted XML) and in theory error [2]. However in no case will there be anything delivered by the error[2] pipe.
Doing diligence I was able to find a universal "translation" for exit = 1, being, incorrect parameters passed.
Is this the case with krpanotools when leveraging encrypt? Is there a known set of exit codes for krpanotools that I could have access to?
Below is the section of code relevant to this situation.
Any help, insight or direction would be greatly appreciated.
$desc = [ 1 => ['pipe', 'w'], // STDOUT
2 => ['pipe', 'w'], // STDERR
];
$proc = proc_open(KRTOOLS_PATH . ' encrypt -p -in=' . $my_file_path . ' -out=stdout', $desc, $pipes);
if (is_resource($proc)) {
if ($out = stream_get_contents($pipes[1])) {
echo $out;
}
fclose($pipes[1]);
$err = stream_get_contents($pipes[2]);
if (!empty($err)) {
$enc_error_file = fopen("enc_error_log.txt", "a");
fwrite($enc_error_file, " Error: " . $err . " - ". $my_filename . "\n");
fclose($enc_error_file);
}
fclose($pipes[2]);
$exit_status = proc_close($proc);
}
Display More