glibc

linux 能ping通IP但无法ping 域名

风流意气都作罢 提交于 2019-12-04 06:52:01
vi /etc/nsswitch.conf hosts: files dns networks: files 改成: hosts: files dns wins networks: files 最近碰到了这么一个问题: ping一个域名domain_name的时候提示”ping: unknown host domain_name“,但是ping域名对应的IP地址 (使用host或nslookup获取) 却没有问题。 libc && glibc   标准C库 (the standard C library) 实现了ISO C标准,包含了一套所有C程序都可以使用的函数。libc通常被用作the standard C library的简写。   libc也被用作一个标准C库的实现的名字。在19世纪90年代早期,Linux内核的开发者把glibc 1.x独立了出来 (forked glibc),并把它称为”Linux libc”,也简称为libc。Linux libc主要发布了2, 3, 4, 5四个版本。   1997年,FSF发布了glibc 2.0,它对POSIX标准有更好的支持,并且代码的可移植性更好。因此,现在所有主要的Linux发行版都是使用glibc。   Linux libc的最后的so-name是libc.so.5。因此后来的glibc 2.x使用的so

How to intercept file system access inside dlopen()?

…衆ロ難τιáo~ 提交于 2019-12-04 06:38:06
I want to intercept all file system access that occurs inside of dlopen(). At first, it would seem like LD_PRELOAD or -Wl,-wrap, would be viable solutions, but I have had trouble making them work due to some technical reasons: ld.so has already mapped its own symbols by the time LD_PRELOAD is processed. It's not critical for me to intercept the initial loading, but the _dl_* worker functions are resolved at this time, so future calls go through them. I think LD_PRELOAD is too late. Somehow malloc circumvents the issue above because the malloc() inside of ld.so does not have a functional free()

Why does glibc “timezone” global not agree with system time on DST?

半世苍凉 提交于 2019-12-04 06:27:31
I'm experiencing a bizarre issue where my system clock knows that it's daylight savings time, but glibc seems not to. This is an up-to-date Ubuntu installation, and I have checked /etc/localtime and it has the correct changeover time for last week's switch to DST. The current correct timezone for me is Pacific Daylight Time (UTC-7). When I ask my system what time zone I'm in, it tells me correctly: $ date +%z -0700 But when I run the following program: #include <time.h> #include <stdio.h> int main() { tzset(); printf("%lu\n", timezone); return 0; } The output is, incorrectly: 28800 Which

Using glibc, why does my gethostbyname fail after I/DHCP has changed the DNS server?

六眼飞鱼酱① 提交于 2019-12-04 05:40:52
If our server (running on a device) starts before a DHCP lease had been acquired then it can never connect using a hostname. If that happens it can find hosts by IP address but not by DNS. I initially thought that the Curl DNS cache was at fault as the curl connections failed. But I used CURLOPT_DNS_CACHE_TIMEOUT to prevent curl from caching address but connections still failed. It turns out that glibc gethostbyname_r won't automatically reload it's configuration if that configuration changes. You have to manually call res_init. See bug report below. Note: Neither the man page for

glibc application holding onto unused memory until just before exit

我怕爱的太早我们不能终老 提交于 2019-12-04 05:30:14
问题 I have a C++ application (gcc 4.9.1, glibc 2.17) running on linux (Centos 7). It uses various third-party libraries, notably Boost 1.61. As the application runs, I can watch its memory usage increasing steadily via htop's VIRT and RES columns, or the ps command, etc. If I let it go long enough, it will use enormous amounts of that memory and swamp the box. Sounds like a leak, but it passes valgrind with only a few bytes leaked, all in places I'd expect. Debug print messages indicate program

how gcc automatically know to include glib library

萝らか妹 提交于 2019-12-04 05:19:29
问题 I make simple program in C which uses glib.h , but when I compile it I get an error like: $ gcc test.c -o test test.c:3:18: fatal error: glib.h: No such file or directory compilation terminated. So from above it seems gcc can't find glib.h file (which is a part of the libglib2.0-dev package and have already installed it). So first I try locate glib.h files in my system and found output as below: $ locate glib.h /usr/src/linux-headers-3.2.0-29-generic-pae/include/config/blk/dev/bsglib.h /usr

Why glibc binary is called libc.so.6 not a libc.so.1 or libc.so.4?

只谈情不闲聊 提交于 2019-12-04 05:07:47
The modern glibc binary is called libc.so.6 in Linux. Why is "6" used here? The libc.so.1 or libc.so.8 can be good names too IMHO. Wikipedia gives some history at http://en.wikipedia.org/wiki/GNU_C_Library but doesn't explain fully In the early 1990s, the developers of the Linux kernel forked glibc. Their fork, called "Linux libc", was maintained separately for years and released versions 2 through 5. When FSF released glibc 2.0 in January 1997, .... At this point, the Linux kernel developers discontinued their fork and returned to using FSF's glibc.[6] The last used version of Linux libc used

Building GCC with glibc in a non-standard location without root

假装没事ソ 提交于 2019-12-04 05:04:41
I have a system that I do not have root access to, but I need to install the current version of GCC (4.7.2) on. The system is running an x86_64 build of Linux 2.6.18 and already has GCC 4.1 (without C++ support even though --version says it was built with it). EDIT 5: At this point, the steps below are just one set of things that I've tried. I've started clean a few times since then. I'm looking for someone to detail the exact order I need to make everything in with all of the switches required. This is the process I've gone through so far (where ROOT is a folder in my home directory) make-3

fixed CHAR_BIT on various systems?

心已入冬 提交于 2019-12-04 04:42:03
问题 I am confused about CHAR_BIT in limits.h. I have read some articles saying the macro CHAR_BIT is there for portability. To use the macro not a magic number like 8 in code, this is reasonable. But limits.h is from glibc-headers and it's value is fixed as 8. If glibc-headers is installed on a system on which a byte has more than 8 bits (say 16 bits), is that wrong when compiling? A 'char' is assigned 8 bits or 16 bits? And when I modified CHAR_BIT to 9 in limits.h, the following code still