Thanks everybody for proposals. Seems I found a solution - call lua_sethook() from different thread, if I decided to terminate script execution (measured big CPU time consumption). It's working in usual lua implementation. But it's not working in luajit - hook is not called immediately after lua_sethook() call in other thread, only at script end. Example: http://pastebin.com/HdnfVQKB Main question is: is there other way to interrupt lua_State from other thread? Consistency of interrupted lua_State is not necessary but preferred, I only need return from luaL_dostring() in main thread with non-zero result. --- С уважением, Киранов Александр 2014-11-05 14:02 GMT+03:00 Victor Bombi <sonoro@xxxxxxxxxxxxxx>: > May be using luaLanes and lane priorities? > I have not tested in linux but only on win32 > > ----- Original Message ----- > *From:* Alexander Altshuler <altexy@xxxxxxxxx> > *To:* luajit@xxxxxxxxxxxxx > *Sent:* Wednesday, November 05, 2014 10:54 AM > *Subject:* Re: luajit state CPU time limit > > On 4 November 2014 22:47, Javier Guerra Giraldez <javier@xxxxxxxxxxx> > wrote: > >> On Tue, Nov 4, 2014 at 2:34 PM, Александр Киранов <xhaskx@xxxxxxxxx> >> wrote: >> > So, when some lua_State consumed too many CPU I need to know it and >> handle >> > it on LUA or on C level. >> >> >> better handle it at the OS level. Linux includes many different tools >> to limit resources. LXC and cgroups spring to mind. I would start >> here: https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt >> >> > But you will have to decompose your application into some processes to get > proper control granularity. > > Regards > Alexander > >