Skip to content

How to get all lua_states? #1305

Answered by vegorov-rbx
heanrum asked this question in Q&A
Discussion options

You must be logged in to vote

There is no API to traverse all states.
There's actually no public API in Lua for this as well, looking into internal details might require rework on every update as that's not a stable API.
Starting from Lua 5.2, allgc doesn't actually link all collectible objects.

Anyway, you use luaM_visitgco.

luaM_visitgco(L, proto, [](void* context, lua_Page* page, GCObject* gco) {
    if (gco->gch.tt != LUA_TTHREAD)
        return false;

    lua_State* th = gco2th(gco);
    return false;
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by heanrum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants