5

系统调用之 restart_syscall

 1 year ago
source link: https://forrestsu.github.io/posts/linux/restart-syscall/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

系统调用之 restart_syscall

2018年12月25日
| 字数 396
| Linux
| 阅读 686

在我们使用strace -p pid 的时候,经常会遇到如下情景:

restart_syscall 究竟是个什么系统调用呢?什么时候会用到该系统调用呢?

先看看我们这个线程的代码:

 std::future<int> f1 = std::async(std::launch::async, []() {
        std::cout << "[B] thread id [async]: " << gettid() << endl;
        sleep(10);
        std::cout <<"[B] f1 exit!" <<endl;
        return 8;
    });

我们只是使用std::async() 创建了一个线程,然后向屏幕打印一行日志。
我们查一下 man 手册:

该系统调用没有 glibc 包装器,因为它仅供内核使用,并且永远不应该由应用程序调用。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK