【发布时间】:2013-06-24 11:09:32
【问题描述】:
所以我写了一个程序来测试 64 位 kubuntu linux 上的线程,版本 13.04。实际上是我从正在编写测试程序的其他人那里窃取了代码。
#include <cstdlib>
#include <iostream>
#include <thread>
void task1(const std::string msg)
{
std::cout << "task1 says: " << msg << std::endl;
}
int main(int argc, char **argv)
{
std::thread t1(task1, "Hello");
t1.join();
return EXIT_SUCCESS;
}
我编译使用:
g++ -pthread -std=c++11 -c main.cpp
g++ main.o -o main.out
然后跑:
./main.out
顺便说一句,当我输入“ls -l”时,main.out 与所有可执行文件一样以绿色文本显示,但名称末尾也有一个星号。这是为什么呢?
回到手头的问题:我跑main.out的时候,出现了一个错误,里面说:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted (core dumped)
有人知道如何解决这个问题吗?
【问题讨论】:
标签: c++ multithreading c++11 std-system-error