zoukankan      html  css  js  c++  java
  • boost的named_mutex的一些坑

    最近遇到一个问题,程序在a用户下运行后,然后注销windows,登陆b用户,发现程序奔溃,抓了下堆栈,发现了boost的named_mutex一些细节,记录下

    #include <boost/interprocess/sync/named_mutex.hpp>
    #include <boost/interprocess/creation_tags.hpp>
    boost::interprocess::named_mutex mutex(boost::interprocess::open_or_create, "haha");
    1.这段代码在a用户运行后,注销,在运行b用户,直接崩溃
    解决方案
    boost::interprocess::permissions per;
    per.set_unrestricted();
    boost::interprocess::named_mutex mutex(boost::interprocess::open_or_create, "haha",per);
    
    文件中的几个值的意义
    UninitializedSegment, //0
    InitializingSegment, //1
    InitializedSegment, //2
    CorruptedSegment //3
    定义在boostinterprocessdetailmanaged_open_or_create_impl.hpp
    开始初始化为1,进程退出的时候改为2
     
    2.文件创建在priv_open_or_create函数里面,其中文件夹在create_device里面创建,该函数最终调用
    get_last_bootup_time(boostinterprocessdetailwin32_api.hpp) 函数会根据系统的事件来获取启动时间,
    如果进程启动之前,系统的日志被一些清理工具清理掉了,那么就会触发异常
     
  • 相关阅读:
    Effective C++ 1.让自己习惯C++
    C++Primer 第十九章
    C++Primer 第十八章
    C++Primer 第十七章
    C++Primer 第十六章
    C++Primer 第十五章
    C++Primer 第十四章
    ~~在python中踩过的坑以及问题~~(不断更新)
    ~~Python解释器安装教程及环境变量配置~~
    ~~Py2&Py3~~
  • 原文地址:https://www.cnblogs.com/ultracpp/p/6832201.html
Copyright © 2011-2022 走看看