摘要:使用多线程时,pthread_create的参数flag有CLONE_FILES, 最终调用do_fork(),并且会根据CLONE_FILES标志来调用copy_files()来共享父进程中的文件描述符(这里包括socketfd)。 使用多进程时,fork的参数flag没有CLONE_FILES,
阅读全文
随笔分类 - linux应用
摘要:使用多线程时,pthread_create的参数flag有CLONE_FILES, 最终调用do_fork(),并且会根据CLONE_FILES标志来调用copy_files()来共享父进程中的文件描述符(这里包括socketfd)。 使用多进程时,fork的参数flag没有CLONE_FILES,
阅读全文
摘要:第一题: //fork1.c #include <unistd.h> #include <stdio.h> int main(void) { int i = 0; for(i = 0; i < 3; i++) { pid_t fpid = fork(); if(fpid == 0) { printf
阅读全文
摘要:One of the features merged in the 3.9 development cycle was TCP and UDP support for the SO_REUSEPORTsocket option; that support was implemented in a s
阅读全文
摘要:一、安装valgrind 安装valgrind,正常的三部曲configure/make/make install就行。 二、memchk使用 1、执行命令 [root@10g-host4 tools]# valgrind --track-fds=yes --log-file=memchk-svr.
阅读全文
摘要:要谈segment fault,必须要谈指针。 指针的本质是什么?只不过是一种带*的数据类型,其特色有: 1、宽度 2、声明 3、赋值 4、++与-- 5、+与- 6、求差值 7、比较 当声明int *ptr = 0x0之后,ptr1就是一个指针变量了, 可以对ptr1做++,--,+,-等各种操作
阅读全文
|