fcntl(fd, F_SETFD, FD_CLOEXEC)

摘自:https://blog.csdn.net/zhangqingsup/article/details/6668203?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-4.control

 fcntl(fd, F_SETFD, FD_CLOEXEC); // 这里设置为FD_CLOEXEC表示当程序执行exec函数时本fd将被系统自动关闭,表示不传递给exec创建的新进程, 如果设置为fcntl(fd, F_SETFD, 0);那么本fd将保持打开状态复制到exec创建的新进程中

posted @ 2020-12-24 16:43  LiuYanYGZ  阅读(512)  评论(0编辑  收藏  举报