Difference between Linux errno 23 and Linux errno 24

拟墨画扇 提交于 2019-11-30 08:55:48

问题


  1. What is the difference between these 2 linux errors in errno.h? 23 and 24

    I tried 2 different sites but can't understand difference between the two.


    [EMFILE]
    Too many open files.
    [ENFILE]
    Too many files open in system.
    

    # define ENFILE      23  /* File table overflow */
    # define EMFILE      24  /* Too many open files */
    

  2. Also, I am getting errno 24 and socket call failing at 974th time. (AF_INET UDP datagram socket)

    When I did a cat /proc/sys/fs/file-max I am seeing a value of 334076 ulimit -n showing 1024

    Any idea what can be done to increase limit?


回答1:


For 1) Both error codes are about the situation with too many opened files. EMFILE is too many files opened in your process. ENFILE is too many files opened in the entire system.




回答2:


You can increase the maximum number of open files / file descriptors

sysctl -w fs.file-max=100000

Or open

/etc/sysctl.conf

and append/change fs.file-max to the number you need:

fs.file-max = 100000

Then run

sysctl -p

to reload the new settings

If you don't want to set system-wide FD (file-descriptor) limits, you can set the user-level FD limits.

You need to edit /etc/security/limits.conf file

And for user YOUR_USER, add these lines:

YOUR_USER soft nofile 4096
YOUR_USER hard nofile 10240

to set the soft and hard limits for user YOUR_USER.
Save and close the file.

To see the hard and soft limits for user YOUR_USER:

su - YOUR_USER

ulimit -Hn
ulimit -Sn


来源:https://stackoverflow.com/questions/24862733/difference-between-linux-errno-23-and-linux-errno-24

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!