Jump to content




Terminate background parallels


2 replies to this topic

#1 LNETeam

  • Members
  • 111 posts
  • LocationEclipse

Posted 21 September 2014 - 04:50 PM

Quick question.

Lets say I do this:

local ops = {function() shell.run("shell") end, mon (this is a internal function)}
parallel.waitForAny(unpack(ops))

So in theory I have a background process. Now, from another program, I wanted to terminate the 'mon' process, is that possible?

> some_program --kill

This terminates the mon 'thread'.

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 21 September 2014 - 05:13 PM

You could communicate through os.queueEvent and os.pullEvent.

--#bla bla bla stuff

--#now we want to kill it
os.queueEvent( "kill_mon" )
And in mon:
local event = { os.pullEvent() }
if event[ 1 ] == "kill_mon" then
  return
end

Also, if you want to kill only one, you would have to use parallel.waitForAll.

#3 LNETeam

  • Members
  • 111 posts
  • LocationEclipse

Posted 21 September 2014 - 05:23 PM

Thanks it works

Wait. From a different program?
Just kidding, had to do some fiddling

Edited by LNETeam, 21 September 2014 - 05:45 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users