lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Apr 11, 2013 at 3:52 AM, oliver <oliver.schoenborn@gmail.com> wrote:
Very useful for sure. Is there anything like this on Windows? Python's subprocess module allows to feed a process's stdin and read its stdout and stderr independent of OS platform.

For sure indeed!  winapi allows the capture of interactive processes:

http://stevedonovan.github.io/winapi/topics/readme.md.html

If you use read_async that calls a callback with each received chunk, then you can capture multiple such processes in parallel.

The Unix concept of 'pseudo terminals' (ptys) is most elegant - you arrange the process to run in a pty, and then control the properties of that pty as if it were a 'real' terminal connected e.g. to a serial connection. So you can arrange to buffer by line, etc.  Whereas with the Windows CreateProcess method used by winapi, the received data won't generally be single lines, and stitching them together is up to you.

I've occaisionally thought it would be cool to have a cross-platform module which provided these useful OS features in a high-level way, rather like that Python module. The implementation would use winapi, luaposix or Justin Cormark's ljsyscall for LuaJIT.