#Scenario:
I'm executing codes in python by proc_open, using py.exe.
Ex:
proc_open('py.exe file.py', $descriptorspec, $pipes, null, null)
My python code can have input or outputs in a undefined sequence.
Ex:
a = input('insert a value')
print(a)
or
print('Hello, this is a program!')
input('insert a value')
#Outputs:
To get outputs I'm using fread.
#Inputs:
To get inputs I'm using fwrite.
#Problem:
Since I have an undefined sequence in python code, I don't know if my program (python code) expect an input or an output. If my program expect a input and I execute fread (output) command, my PHP will enter in a looping... waiting for nonexistent python output.
#Question
I can check in "pipes" if my python aplication is waiting a input or a output?
P.S: If it is not possible, how a can solve this problem?
There is apparently no native solution to the problem. For now, I am attaching a non-printable character (0) to the user input.
original print: input("enter with one number")
modified print: input(chr (0) + "enter with one number")
In this way I can use a flag (out/in)
;)