lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks!

Moving to luaL_openlibs solve the problem and I now understanding why it's not possible to call it directly.

The only problem left for me:

Let's say that I'm creating a thread that is running a Lua based script that take a lot of time to run (or even an end-less loop). At some time (let's say on shutdown) I want to tell the lua engine to stop. What I need is a function on the Lua engine that can terminate a current lua script, so another thread (the main thread) can force terminating a script running on the Lua thread. I can add a special function that allow the script to check for shutdown (that's what I'm doing now) but it depending on the script writer to use it, else the application will not be able to close.

It shouldn't be a hard task. It can be done by checkig a flag on the main big loop that executing a Lua script and a special function that can turn on this flag.

On Fri, Jan 23, 2009 at 1:21 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> 3: The luaopen_* methods cannot be called directly from C; they should
> be called as Lua C functions like so:
> lua_pushcfunction(L, luaopen_io);
> lua_pushliteral(L, "io");
> lua_call(L, 1, 0);
> Or, like so:
> lua_cpall(L, luaopen_io, "io");

Or just call luaL_openlibs, editing lualibs in linit.c to suit your needs.
linit.c is meant to be edited and added to your app.