atfork专题

muduo网络库学习之Exception类、Thread 类封装中的知识点(重点讲pthread_atfork())

一、Exception类封装 class  Exception  : public  std::exception  #include <execinfo.h>  int backtrace(void **buffer, int size); //  backtrace 栈回溯,保存各个栈帧的地址  char **backtrace_symbol

pthread_create()和pthread_atfork()函数使用时应注意的问题

pthread_create()和pthread_atfork()函数使用时应注意的问题 由于 pthread 库不是 Linux 系统默认的库,连接时需要使用库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,在编译中要加 -lpthread参数。 例如:在加了头文件#include <pth