在“http_listener.h”中处理中断信号时使用 Microsoft CppRestSdk

问题描述

我正在使用“https://github.com/microsoft/cpprestsdk”v2.8 并尝试处理中断信号,但“cpprest/http_listener.h”给出了分段错误。 如果我注释掉第 3 行(#include )服务器将停止而不会出现任何分段错误

enter image description here

我的代码片段如下

#include <iostream>
#include <cpprest/http_listener.h>

void signal_handler(int signal) {
    std::wcout<<"Exiting the program... ::" << signal << std::endl;    
    exit(EXIT_SUCCESS);
}

int main(int argc,char** argv) {
    //Registring a signal handler to prevent abrupt exits
    std::signal(SIGINT,signal_handler);

    try {
        while (true);   
    }
    catch (std::exception const & e) {
        std::wcout << e.what() << std::endl;
    }  
    
    return 0;
}

使用的版本:
操作系统 - Linux 16.04
CPP REST 版本 - 2.8
G++ 版本 - 7.5.0

编译上述代码片段的命令 - g++ test.cpp -o spike_op1 -lcpprest -lssl -lcrypto -lpthread

所以 cpprest/http_listener.h 文件中存在问题,有人有解决方案吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)