On Fri, Oct 5, 2012 at 1:10 PM, Paul K <paulclin...@yahoo.com> wrote: > Hi João, > > Thanks again for your example, as I ended up with something that was > closer to yours than to my original plan (as mine was blocking the app > if the other application wasn't printing anything). For those who are > following the thread, this is what I ended up with: > > local proc = wx.wxProcess() > proc:Redirect() > proc:Connect(wx.wxEVT_END_PROCESS, function(event) proc = nil end) > local bid = wx.wxExecute(cmd, wx.wxEXEC_ASYNC + > wx.wxEXEC_MAKE_GROUP_LEADER, proc) > if not bid or bid == -1 or bid == 0 then > DisplayOutput(("Program unable to run as '%s'\n"):format(cmd)) > return > end > > local streamin = proc:GetInputStream() > for _ = 1, 10 do > if streamin:CanRead() then > -- do something with streamin:Read(4096) > end > wx.wxSafeYield() > wx.wxWakeUpIdle() > wx.wxMilliSleep(250) > end
The wxWidgets exec sample uses a wxTimer to poll the stream for data. You just have to connect to wxEVT_END_PROCESS and turn off the timer when it exits or kill it like you do if it doesn't respond in a timely fashion. See, MyFrame::OnExecWithRedirect() and MyFrame::AddPipedProcess() http://svn.wxwidgets.org/viewvc/wx/wxWidgets/trunk/samples/exec/exec.cpp?view=markup Regards, John ps. My previous comment was to confirm that you have seen the docs and are doing all the checks. My experience with processes is that they can be finicky if things aren't just right. In fact, you should always connect to wxEVT_END_PROCESS in case the user or OS kills your process for you... ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users