Jump to content




Coroutine and os.run


  • You cannot reply to this topic
2 replies to this topic

#1 Pinkishu

  • Members
  • 484 posts

Posted 13 August 2012 - 03:19 AM

Hi there, ran into a little problem with coroutines:

local function host(path,...)
print("S")
local p1,p2=os.run( _G, path, unpack(arg))
print("E")
end

local co = coroutine.create(host)
coroutine.resume(co,"mtshell")
print(coroutine.status(co))

this does not run the file. the "S" gets printed the "E" does not and the coroutine status winds up being "dead".
Any ideas?

#2 BigSHinyToys

  • Members
  • 1,001 posts

Posted 13 August 2012 - 04:04 AM

you cant run it in _G environment make a new one for the running program example
local function host(path,...)
    print("S")
    local p1,p2=os.run( {}, path, unpack(arg))
    print("E")
end
local co = coroutine.create(host)
coroutine.resume(co,"mtshell")
print(coroutine.status(co))


#3 Pinkishu

  • Members
  • 484 posts

Posted 13 August 2012 - 12:21 PM

Ah ok :> thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users