linux下confstr与uname函数_获取C库与内核信息
来源:互联网 发布:业务流程优化的目的 编辑:程序博客网 时间:2024/06/05 02:01
#include <stdio.h>#include <sys/utsname.h>//unameint main(int argc, char **argv[]){struct utsname u;if (uname(&u) != -1) {printf("获取当前内核的名称和信息如下\n" "sysname:%s\n" "nodename:%s\n" "release:%s\n" "version:%s\n" "machine:%s\n" , u.sysname, u.nodename, u.release, u.version, u.machine);}return 0;}
输出如下:
获取当前内核的名称和信息如下sysname:Linuxnodename:fesrelease:2.6.32-220.el6.x86_64version:#1 SMP Wed Nov 9 08:03:13 EST 2011machine:x86_64size_t confstr(int name, char *buf, size_t len);
confstr函数获取依赖配置的字符串变量的值
1、_CS_GNU_LIBC_VERSION,the GNU C library version on this system
2、_CS_GNU_LIBPTHREAD_VERSION,the POSIX implementation supplied by this C library
3、_CS_PATH,A value for the PATH variable which indicates where all the POSIX.2 standard utilities can be found.
#include <stdio.h>#include <stdlib.h>#include <unistd.h>//confstrint main(int argc, char **argv[]){char *pathbuf, *gun_libpthread_version_buf, *gun_libc_version_buf;size_t n;n = confstr(_CS_PATH,NULL,(size_t) 0);pathbuf = malloc(n);if (pathbuf == NULL)abort();confstr(_CS_PATH, pathbuf, n);printf("_CS_PATH, A value for the PATH variable:%s\n", pathbuf);free(pathbuf);pathbuf = NULL;n = confstr(_CS_GNU_LIBPTHREAD_VERSION,NULL,(size_t) 0);if (n > 0) {gun_libpthread_version_buf = malloc(n);}if (gun_libpthread_version_buf == NULL)abort();confstr(_CS_GNU_LIBPTHREAD_VERSION, gun_libpthread_version_buf, n);printf("_CS_GNU_LIBPTHREAD_VERSION, the POSIX implementation supplied by this C library:%s\n", gun_libpthread_version_buf);free(gun_libpthread_version_buf);gun_libpthread_version_buf = NULL;n = confstr(_CS_GNU_LIBC_VERSION,NULL,(size_t) 0);if (n > 0) {gun_libc_version_buf = malloc(n);}if (gun_libc_version_buf == NULL)abort();confstr(_CS_GNU_LIBC_VERSION, gun_libc_version_buf, n);printf("_CS_GNU_LIBC_VERSION, the GNU C library version on this system: %s\n" \, gun_libc_version_buf);free(gun_libc_version_buf);gun_libc_version_buf = NULL;return 0;}输出结果如下:
_CS_PATH, A value for the PATH variable:/bin:/usr/bin_CS_GNU_LIBPTHREAD_VERSION, the POSIX implementation supplied by this C library:NPTL 2.12_CS_GNU_LIBC_VERSION, the GNU C library version on this system: glibc 2.12
0 0
- linux下confstr与uname函数_获取C库与内核信息
- confstr--Linux下获取C标准库信息的函数
- Linux内核栈信息获取与理解
- Linux内核栈信息获取与理解
- Linux内核栈信息获取与理解
- Linux内核栈信息获取与理解
- Linux内核栈信息获取与理解
- Linux命令之获取操作系统信息-uname
- linux下C编程_获取指定网卡IP信息
- Linux下系统信息查询 -- uname命令
- uname获取系统信息
- 每日掌握一个Linux命令 之 查看内核信息 uname
- Linux内核映像中的内核配置信息生成与获取详解
- linux内核与c标准库
- linux获取内核信息
- Linux uname --打印系统信息
- linux下获取IP等信息函数
- linux下C语言中的mkdir函数与rmdir函数
- awk求某列的和
- Code::Blocks环境下创建并显式调用动态链接库
- 【学习笔记】Firefox的restclient插件是个好东东~
- HOJ 13083 Quite Good Numbers(其实是暴力)
- Android 的SQLiteDataBase简要知识点
- linux下confstr与uname函数_获取C库与内核信息
- openssl之BIO系列之6---BIO的IO操作函数
- wxython简单入门加实例3:创建菜单栏
- Milestone/umts_sholes/OMAP3430 DSS(Display Sub-System) Go-Through
- 如何在windows中查看,端口被什么应用程序占用
- undefined reference to 'pthread_create'问题解决
- AAC 音频格式分析.
- Ext中new 和create的区别
- openssl之BIO系列之7---BIO链的操作