Re: [code] [textadept] output from spawn on Windows?

From: Mitchell <>
Date: Wed, 11 Feb 2015 12:05:48 -0500 (EST)

Hi Mateusz,

On Tue, 10 Feb 2015, Mateusz Czaplinski wrote:

> On Tue, Feb 10, 2015 at 2:15 AM, Mitchell <> wrote:
>> Hi Mateusz,
>> On Tue, 10 Feb 2015, Mateusz Czaplinski wrote:
>> pp=spawn('git --version',_USERHOME,ui.print,ui.print,ui.print) pp:wait()
>>> ui.print('hi')
>>> and the output I get is:
>>> hi
>>> git version 1.9.4.msysgit.2
>>> 0
>>> so, the callbacks are apparently still called async, long after the
>>> :wait()
>>> has finished. So that's probably why I wasn't able to capture anything?
>>> That doesn't seem to give me much hope as to processing the command's
>>> output and doing something useful afterwards in a synchronous way...
>> Calling `pp:wait()` blocks Lua, preventing async callbacks from running
>> until after the current Lua function (which in your case includes printing
>> 'hi' first). If you want to synchronously read a process' output, use
>> `pp:read()` without `pp:wait()`.
>> The simplest thing I can do is from the command entry:
>> =spawn('ruby -v'):read('*a')
>> This works just fine.
> Ok, for a simple command, read() worked, thanks. But then, via read() I
> can't get the STDERR output, unfortunately, right? Nor the exit code of the
> process?

You should be using Lua's `io.popen()` if you're interested in synchronous
reading from processes (including stderr) with exit code. If you really
want to use `spawn()`, you can try to use a command that redirects stderr
to stdout, but I don't think you'll be able to get the exit code. Feel
free to submit a patch[1] to save and access exit code for a process.



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Wed 11 Feb 2015 - 12:05:48 EST

This archive was generated by hypermail 2.2.0 : Thu 12 Feb 2015 - 06:47:37 EST