曲阳县做网站,怎么推广业务,石家庄有学校交做网站和优化的吗,手机怎么制作网站教程Linux中#xff0c;文件描述符有一个属性#xff1a;CLOEXEC#xff0c;即
当调用exec#xff08;#xff09;函数成功后#xff0c;文件描述符会自动关闭。在以往的内核版本#xff08;2.6.23以前#xff09;中#xff0c;需要调用 fcntl(fd, F_SETFD, FD_CLOEXEC) 来… Linux中文件描述符有一个属性CLOEXEC即
当调用exec函数成功后文件描述符会自动关闭。在以往的内核版本2.6.23以前中需要调用 fcntl(fd, F_SETFD, FD_CLOEXEC) 来设置这个属性。而
新版本2.6.23开始中可以在调用open函数的时候通过 flags 参数设置 CLOEXEC 功能如 open(filename, O_CLOEXEC)。 虽然新版本支持在open时设置CLOEXEC但是在编译的时候还是会提示错误 - error: ‘O_CLOEXEC’ undeclared (first use in this function)。原来这个新功能要求我们手动去打开需要设置一个宏(_GNU_SOURCE)。可通过以下两种方法来设置这个宏以打开新功能
1. 在源代码中加入 #define _GNU_SOURCE 2. 在编译参数中加入 -D_GNU_SOURCE gcc 还有很多其他的开关具体可以参考
--------------------------- /usr/include/features.h -----------------------------------------------
These are defined by the user (or the compiler) to specify the desired environment: __STRICT_ANSI__ ISO Standard C. _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. _POSIX_SOURCE IEEE Std 1003.1. _POSIX_C_SOURCE If 1, like _POSIX_SOURCE; if 2 add IEEE Std 1003.2; if 199309L, add IEEE Std 1003.1b-1993; if 199506L, add IEEE Std 1003.1c-1995; if 200112L, all of IEEE 1003.1-2004 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if Single Unix conformance is wanted, to 600 for the upcoming sixth revision. _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. _LARGEFILE_SOURCE Some more functions for correct standard I/O. _LARGEFILE64_SOURCE Additional functionality from LFS for large files. _FILE_OFFSET_BITSN Select default filesystem interface. _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. _SVID_SOURCE ISO C, POSIX, and SVID things. _ATFILE_SOURCE Additional *at interfaces. _GNU_SOURCE All of the above, plus GNU extensions. _REENTRANT Select additionally reentrant object. _THREAD_SAFE Same as _REENTRANT, often used by other systems. _FORTIFY_SOURCE If set to numeric value 0 additional security measures are defined, according to level. ------------------------------------------------------------------------------------------