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
-- kill process if couldn't read after 10 attempts
-- wx.wxProcess.Kill(bid, wx.wxSIGKILL, wx.wxKILL_CHILDREN)
Paul.
On Mon, Oct 1, 2012 at 4:03 AM, João Mendes lord@gmail.com wrote:
Hi Paul,
Did you try this:
proc = wx.wxProcess()
proc:Connect(wx.wxEVT_END_PROCESS,
function(event)
print(Hello - the process is over and won't be deleted.)
-- event:Skip(true) -- will crash since wxWidgets will delete it
too
-- proc = nil
-- collectgarbage( collect ) -- not necessary, but it tests the
problem
end
)
proc:Redirect()
wx.wxExecute( cmd, wx.wxEXEC_ASYNC, proc )
I get this code somewhere and work fine for me.
--
João Mendes de Oliveira Neto
2012/9/30 Paul K paulclin...@yahoo.com
Hi All,
I'm trying to read output from a program and am having trouble with
the following three lines of code:
local proc = wx.wxProcess(wx.NULL, wx.wxPROCESS_REDIRECT)
local pid = wx.wxExecute(cmd, wx.wxEXEC_ASYNC, proc)
local streamin = proc:GetInputStream()
The app crashes on any attempt to get input stream. The following code
with EXEC_SYNC works fine though:
local pid = wx.wxExecute(cmd, wx.wxEXEC_SYNC)
But this doesn't give me any way to access the output of the command I
execute.
I suspect the problem is in the first parameter in wxProcess:
wx.wxProcess(wx.NULL, but I don't see any other way to not provide
wxEvtHandler or create a dummy one (replacing wx.NULL with
wx.wxEvtHandler() has the same effect: the app crashes).
This is all on windows 7 running fairly recent 2.8.12.2 code. I'd
appreciate any ideas on how to get program output. Thanks.
Paul.
--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users
--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users
--
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