lua-users home
lua-l archive

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

It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> > > Are there other, better alternatives to limit the CPU time?
> > 
> >   Under Unix, you can call setrlimit(), or ulimit from the command line, to
> > limit not only CPU, but memory resources as well.
> These will kill the process when the time runs out, won't they?
> That's not suitable for a program that embeds Lua and wants to limit
> CPU time or memory used by Lua programs.

  Not necessarily.  When the CPU time has exceeded the value set by
setrlimit(), a SIGXCPU is sent, which means you can catch that and handle
the situation appropriately (default action is to kill the program).  When
the memory limits are set, malloc() returns NULL with errno set to ENOMEM.

  But again, this is under Unix.