プログラム実行時に「Too many open files」とか出たら、
「1プロセスが同時にオープンできるファイルの最大数」
「システム全体で同時にオープンできるファイルの最大数」を
の上限に引っ掛かっている可能性が高いので、
$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited pending signals (-i) 1024 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 stack size (kbytes, -s) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 16367 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
で確認する。
open filesが「1プロセスが同時にオープンできるファイルの最大数」、
max user processが「システム全体で同時にオープンできるファイルの最大数」を示す。
上限の修正をするときは
# /etc/security/limits.conf より ユーザ名 soft nofile 32768 ユーザ名 hard nofile 32768 ユーザ名 soft nproc 4096 ユーザ名 hard nproc 4096
を追加して保存。
nofileがopen filesの設定、nprocがmax user processの設定となる。
設定の変更はログインしなおすと反映される(それ以外に方法があるかもしれない・・・・)
ユーザ名の前に@を付与するとグループ名指定になる。
http://okwave.jp/qa3907300.html