ILD

dns配置文件
2017-7-16
glibc解析服务使用的dns服务器地址是通过下述文件配置的:/etc/resolv.conf1234herbert@Lenovo:~$ cat /etc/resolv.conf# Dynamic resolv.conf(5) file for glibc resolver(3) generated

how to check glibc version?
2018-10-19
glibc每半年发布一个版本,分别在8月1号和2月1号左右。2018-08-01: glibc 2.28 released.2018-02-01: glibc 2.27 released.查看glibc的版本,可以:1 调用/lib/libc.so.6123456789101112131415161

syslog
2019-10-8
syslog提供一个机制,给各个应用程序记录日志。glibc提供了接口来发送log给syslog的守护进程,这个守护进程通常是syslogd。c库提供的接口: void openlog(const char *ident, int option, int facility);

getpwuid: No such file or directory解决
2020-1-13
写一个简单的程序调用,使用strace ./a.out,发现是没有拷贝libnss_files库。pwd可以使用file db,访问/etc/passwd文件。openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT

Specifying the Time Zone with TZ
2020-5-5
使用C库的接口获取localtime相关的时间时,需要指定时区,在POSIX系统里,用户通过TZ环境变量的方式指定时区。 通常不需要设置TZ,因为系统通常已经配置好了。但是通过TZ我们可以获得特定时区的时间。比如:$ TZ=EST+5 dateTue 05 May 2020 09:42

understanding glibc malloc
2020-7-3
malloc(size_t n)如果n是0,返回一个最小的chunk,在32位系统上是16字节,在64位系统上是24或32字节。free(void *p)如果p是null,则没有影响。如果p已经被释放,则可能有任意的影响,不要这样做。malloc_trim(size_t pad)将内存交还给系统,堆

你真的了解snprintf吗
2022-10-10
函数原型:#include int snprintf(char *str, size_t size, const char *format, ...);看看musl库的实现:src/stdio/snprintf.c#include #include

snprintf size参数为负数怎么处理
2024-3-9
看如下代码,如果传一个负数,snprintf是不是就不打印了。 char buf[4] = {0}; int ret = snprintf(buf, -1, "abc"); printf("ret %d %s\n", ret, buf);编译告警了:test

recent glibc has removed libcrypt
2024-5-25
在Xrouter平台适配一个新的机型的时候,发现glibc 2.38 版本已经去掉了 libcrypt。导致crypt函数也无法使用了。可替换的库:https://github.com/besser82/libxcrypt[PATCH] Deprecate libcrypt and don't bu

glibc's free() never return heap memory to kernel
2024-11-29
看下面一段测试程序:12345678910111213141516171819202122232425262728293031#include #include #include static void print_mem(){

Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.