【问题标题】:Error:pipe_select_interrupter: Too many open files, on OS LINUX错误:pipe_select_interrupter:打开的文件太多,在 OS LINUX 上
【发布时间】:2015-07-03 04:47:58
【问题描述】:

在我的代码中,我使用了 boost 库,并在 boost::thread: 中第一次运行时得到错误并发生:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'what(): 
pipe_select_interrupter: Too many open files.

我使用了ulimit,看到文件描述符是300000,我认为它不能被使用。 代码抛出错误:

CCohConnection *conn = new CCohConnection(this,CCohStack::GetIoService());

构造函数定义:

CCohConnection::CCohConnection(ICohClient *pClient,boost::asio::io_service &io_service):
        m_pClient(pClient),m_oIoService(io_service),m_socket(io_service),m_resolver(io_service),m_timer(io_service)
    {
        printf("gouzao\n");
    }

我的程序在这个构造函数中中断了,这里是ioservice的定义:

namespace coh{
    class CCohStack
    {
        public:
            static void Start();
            static void Stop();
            static boost::asio::io_service & GetIoService(){return sm_oIoService;}
        private:
            static boost::asio::io_service sm_oIoService;
            static boost::asio::io_service::work *sm_oWork;
            static boost::thread m_thread;
    };
}

【问题讨论】:

  • 我们需要更多代码 (SSCCE)。该代码没有显示资源的生命周期是如何实际管理的。

标签: c++ linux boost


【解决方案1】:

我使用了ulimit,看到文件描述符是300000,我认为它不能被使用。

ulimit -n 获取/设置每个进程的打开文件数限制。您很可能已达到操作系统上打开文件的最大限制。

以下命令可能有助于调查问题:

  • 统计所有进程打开的所有文件:lsof | wc -l
  • 检查您的操作系统硬限制:cat /proc/sys/fs/file-max
  • 增加操作系统硬限制,即:echo 800000 &gt; /proc/sys/fs/file-max

注意:检查/设置限制可能因您的操作系统而异。

【讨论】:

  • 您好,谢谢您的回答,但它不起作用。其实我不认为这真的是限制打开文件的错误。但是代码太多了,我不知道给你看什么。使用boost::asio::ioservice有什么限制吗?
猜你喜欢
  • 1970-01-01
  • 2013-05-11
  • 2011-09-06
  • 2019-02-23
  • 1970-01-01
  • 1970-01-01
  • 2014-10-03
  • 2010-12-07
  • 1970-01-01
相关资源
最近更新 更多