lua-users home
lua-l archive

Non-blocking read from sub-process?

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


I want to run a sub-process that may or may-not generate output. How
can I make sure I don't block trying to read it. I'm happy to use
luaposix, but I'm trying not to use a big event framework like lua-ev
(because I'm memory limited and also don't want to cross compile it).
Something like:
f = io.popen(unknown_command, "r")
while im_doing_something_else:
 data = f:read()
 if data:
 print ("Subproc says: ", data)
kill(sub_proc)
Thanks,
Dan

AltStyle によって変換されたページ (->オリジナル) /