zoukankan      html  css  js  c++  java
  • times(NULL) Segmentation fault

    ******************************************************************************
     *                   times(NULL) Segmentation fault
     * 说明:
     *     在PC机上times(NULL)是没问题的,但在嵌入式Linux上,貌似不传递参数是有可能
     * 会出问题的。
     *
     *                                         2017-7-6 深圳 龙华樟坑村 曾剑锋
     *****************************************************************************/
    
    一、参考文档:
        1. Segmentation fault using ctime
            https://stackoverflow.com/questions/12338947/segmentation-fault-using-ctime    
        2. Segmentation fault on time(0);
            https://stackoverflow.com/questions/1731802/segmentation-fault-on-time0
        3. segmentation fault (core dumped) error when using time function
            https://stackoverflow.com/questions/20939415/segmentation-fault-core-dumped-error-when-using-time-function
       4. An application encounters segmentation fault in glibc's times(2) function
         https://access.redhat.com/solutions/1124633
    二、测试代码: #include <iostream> #include <sys/times.h> #include <unistd.h> using namespace std; int main() { unsigned long SysF = sysconf(_SC_CLK_TCK); struct tms tmp; while(1) { // unsigned long tick = times(NULL); // don't use this. it may cause segmentation fault. unsigned long tick = times(&tmp); unsigned long RetUl = (1000 / SysF) * tick; cout << "tick: " << tick << " RetUl: " << RetUl << endl; usleep(10000); } return 0; }
  • 相关阅读:
    web service 项目 和 普通 web项目 的 区别
    1) Apache Maven 's README.txt
    spring + rs + RocketMQ 【精】
    wadl 的自动生成(cxf版本3.1.1)
    新建maven web 项目后,出现的小问题
    cxf-rs client 调用
    wadl 的自动生成(cxf版本2.7.6)
    Java学习路线
    Tomcat 学习记录
    Spring Boot 学习记录
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/7124462.html
Copyright © 2011-2022 走看看