mirror of
https://github.com/lua/lua
synced 2026-09-26 16:17:11 +03:00
The main thread cannot be closed
No thread started with pcall (instead of resume) can be closed, because coroutine.close would not respect the expected number of results from the protected call.
This commit is contained in:
parent
fd897027f1
commit
e657a48ea5
3 changed files with 10 additions and 2 deletions
|
|
@ -158,6 +158,11 @@ do
|
|||
|
||||
local main = coroutine.running()
|
||||
|
||||
-- cannot close 'main'
|
||||
local st, msg = pcall(coroutine.close, main);
|
||||
assert(not st and string.find(msg, "main"))
|
||||
|
||||
|
||||
-- cannot close a "normal" coroutine
|
||||
;(coroutine.wrap(function ()
|
||||
local st, msg = pcall(coroutine.close, main)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue