[Lazarus] Can't copy TMemoryStream to TProcess.Input
Michael Van Canneyt
michael at freepascal.org
Sun Apr 7 00:04:45 CEST 2013
On Sat, 6 Apr 2013, Leonardo M. Ramé wrote:
> On 2013-04-06 13:22:39 -0300, Leonardo M. Ramé wrote:
>> On 2013-04-06 17:46:06 +0200, Mattias Gaertner wrote:
>>> On Sat, 6 Apr 2013 12:37:06 -0300
>>> Leonardo M. Ramé <l.rame at griensu.com> wrote:
>>>
>>>> [...]
>>>>> Check return value of Proc.Input.Write.
>>>>> And call Proc.CloseInput when your input was written completely.
>>>>>
>>>>>
>>>>
>>>> Mmm, I'm getting the same result.
>>>>
>>>> I attached the new code.
>>>
>>> When you give Proc.Input.Write 200 bytes and it returns that the other
>>> process could only process 100 of them. What bytes do you have to write
>>> next?
>>>
>>
>> Sorry, I'm not getting it. Which other process?, apart from that,
>> Proc.Input.Write is always returning the sizeof(buffer) except when it
>> reaches the end, where it can be less than it.
>>
>> It seems that the Proc.Input part is ok, aparently the Proc.Output is
>> wrong :(
>>
>> I attached a slightly modified code.
>>
>
> Finally got it working, I was forgetting to read the last part of the
> Output stream. ...I still don't know why this last chunk of bytes
> doesn't show up in NumBytesAvailable.
NumBytesAvailable is inherently unreliable. I didn't like it's addition.
You should never use it in critical code.
Michael.
More information about the Lazarus
mailing list