OT: 'best' dynamic language

Manlio Perillo manlio_perillo at libero.it
Sat Apr 26 19:28:38 MSD 2008

Manlio Perillo ha scritto:
> [...]
> I have written a small program and I can confirm that opened files are 
> correctly closed when the Lua interpreter is finalized.
> The program is attached: the Lua code simply open a big file and read 
> all its content in memory.
> There is a custom memory allocator that make sure to fail when a large 
> amount of memory is required.
> There is a strange behaviour, however.
> The status code returned by luaL_dostring should be
> 4 (LUA_ERRMEM), instead 1 is returned.

Ok, solved.

The last luaL_dostring should be replaced with:

   status = luaL_loadstring(L, CHUNCK_2);
   if (status != 0) {
     printf("syntax error in CHUNK_2\n");
     return EXIT_FAILURE;

   status = lua_pcall(L, 0, 0, 0);
   msg = lua_tolstring(L, 1, &len);
   printf("execution status 2: %i:%s\n", status, msg);

since luaL_dostring always returns 1 in case of errors.

Updated code is here: http://rafb.net/p/yOVhjw87.html

Regards  Manlio Perillo

More information about the nginx mailing list