You are not logged in.

  • "Douglas Rhiner" started this thread

Posts: 98

Location: Fairfax, CA

Occupation: Code-Slave

  • Send private message

1

Wednesday, September 26th 2018, 5:28am

krpanotools encrypt exit codes

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.

*confused*


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$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);
}

  • "Douglas Rhiner" started this thread

Posts: 98

Location: Fairfax, CA

Occupation: Code-Slave

  • Send private message

2

Monday, October 1st 2018, 7:43pm

Perhaps I need to take this at a different angle.

Using a set of commands and xml-input that are EXACTLY the same, I run the set via krpanotools encrypt routine 20 times.

Eighteen of the 20 times the process is successful, with an exit code of 0.
Two of the 20 times the process errors with an exit code of 1.


What COULD be potentially causing this result?




  • "Douglas Rhiner" started this thread

Posts: 98

Location: Fairfax, CA

Occupation: Code-Slave

  • Send private message

3

Thursday, October 4th 2018, 2:07am

Klaus,

I have a collection of 44 XML files that have failed encryption via my method at the following link: Link to .zip of files
I've run the contents of each one through several XML validators and they have come up clean.
The version of krpanotools I'm using is krpano-1.19-pr16 Linux 64.
Each one of these has produced an exit code of "1".

Can you, or anyone, see a reason as to why these would cause an error when encrypting?

4

Thursday, October 4th 2018, 9:23am

Hi,

I have tested your files now a several times (but not in server script) and they were always working...


What COULD be potentially causing this result?
There can be basically only two possible reasons:
- the loading of the input file would fail
- or the writing to the output would fail

The writing and the write-checking itself is simple standard C-code - e.g.:

Source code

1
2
3
4
if ( fwrite(data, 1, datacount, filehandle) != datacount )
{
  error
}

That means when there is an error here, the reason should be system related...

Try searching for PHP proc and pipes problems, maybe the reason is there...

Best regards,
Klaus