[erlang-questions] os:cmd/1 does not work for ulimit -n

Cameron Kerr ckerr@REDACTED
Thu May 14 11:34:07 CEST 2009

ulimit is a shell internal command. Every os:cmd opens a new shell.  
The ulimit is inherited by child processes of the shell after the  
ulimit command took effect. It does _not_ affect parent processes,  
which is what the Erlang system process is.

Therefore, in order for the ulimit to change, you need to change the  
ulimit of the Erlang process, OR prefix the command you really want to  
run with ulimit (eg. os:cmd("ulimit -n 2048; bigcommand").

Someone more experienced might be able to tell you how to have the  
Erlang system process try to change its own ulimit, but the most  
common way would be to set this limit before starting 'erl'. Eg, the  
following should work, assuming that the user is allowed to change  
their limit to such a value.

shell$ ulimit -n 2048
shell$ erl

On 14/05/2009, at 9:07 PM, MAthuvathanan Mou. wrote:

> Hi all,
> Using Linux (RedHat) I wanted to increase number of open files for  
> that session only (temporarily)
> In the erl shell I did
> erl
> Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0]  
> [hipe] [kernel-poll:false]
> Eshell V5.5.5  (abort with ^G)
> 1> os:cmd('ulimit -n').
> "1024\n"
> 2> os:cmd('ulimit -n 2048').
> []
> 3> os:cmd('ulimit -n').
> "1024\n"
> 4>
> Why did open file not increase here?
> Regards,
> -- 
> Mathuvathanan Mou.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list