confstr(3) Library Functions Manual confstr(3) confstr - C (libc, -lc) #include size_t confstr(int name, char buf[.size], size_t size); glibc (. feature_test_macros(7)): confstr(): _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE confstr() , . name , . : _CS_GNU_LIBC_VERSION ( GNU C; glibc 2.3.2) GNU C (, <>). _CS_GNU_LIBPTHREAD_VERSION ( GNU C; glibc 2.3.2) , POSIX, C (, <> <>). _CS_PATH PATH, POSIX.2. If buf is not NULL and size is not zero, confstr() copies the value of the string to buf truncated to size - 1 bytes if necessary, with a null byte ('\0') as terminator. This can be detected by comparing the return value of confstr() against size. If size is zero and buf is NULL, confstr() just returns the value as defined below. If name is a valid configuration variable, confstr() returns the number of bytes (including the terminating null byte) that would be required to hold the entire value of that variable. This value may be greater than size, which means that the value in buf is truncated. name -- , , confstr() 0. name , confstr() 0 errno EINVAL. EINVAL name. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |confstr() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2008. POSIX.1-2001. POSIX.2: char *pathbuf; size_t n; n = confstr(_CS_PATH, NULL, (size_t) 0); pathbuf = malloc(n); if (pathbuf == NULL) abort(); confstr(_CS_PATH, pathbuf, n); getconf(1), sh(1), exec(3), fpathconf(3), pathconf(3), sysconf(3), system(3) () Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 15 2024 . confstr(3)