Re: [code] [textadept] Strange behaviour in spawn_proc:write(…)

From: Mitchell <m.att.foicica.com>
Date: Tue, 6 Oct 2015 14:11:35 -0400 (EDT)

Hi Giovanni,

On Mon, 5 Oct 2015, Giovanni Salmeri wrote:

> Hello everybody.
>
> I'm writing a function for Textadept which makes use of spawn and I'm
> observing a strange behaviour. In the following snippet
>
> proc = spawn(...)
> local text = buffer:get_text()
> proc:write(text)
> proc:close()
>
> only the first 64K of text (i.e. exactly 65536 bytes) are actually
> written in the stdin of proc: all the rest seems to be discarded, with
> no error message. But if I add a little pause after the spawning of the
> process, for example like this:
>
> proc = spawn(...)
> local text = buffer:get_text()
> local ntime = os.time() + 1
> repeat until os.time() > ntime
> proc:write(text)
> proc:close()
>
> all the text is regularly written (I discovered that by chance). I have
> no problem in keeping this workaround, but I suspect I am doing
> something wrong. Can someone help me? Thank you!

If you are on Linux, it looks like you are running into the buffer
size limit for pipes, which looks to be 64K. Your workaround is clever.
Perhaps GTK is doing something behind the scenes to buffer the input once
the process has a bit of time to initialize.

Can you break up your input into 64K chunks and pass each individually
without the artificial waiting? That may be the better practice.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 06 Oct 2015 - 14:11:35 EDT

This archive was generated by hypermail 2.2.0 : Wed 07 Oct 2015 - 06:45:57 EDT