I have a small Java program that loops calling InetAddress.getByName("example.com") every second. When I run it on a CentOS 6.4 box using 'strace -f' I see that /etc/resolv.conf is opened and read once:
$ grep /etc/resolv.conf strace.out
[pid 24810] open("/etc/resolv.conf", O_RDONLY) = 6
When I run it on Debian 7 I see that /etc/resolv.conf is repeatedly opened or stat()'d:
$ grep /etc/resolv.conf strace.out
[pid 41821] open("/etc/resolv.conf", O_RDONLY) = 10
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
[pid 41821] open("/etc/resolv.conf", O_RDONLY) = 10
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
[pid 41821] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
Both systems have /etc/nsswitch.conf configured with
hosts: files dns
Neither system has a name caching daemon running.
I used the same version of the Oracle HotSot Java JVM on both machines to rule out any Java differences.
The CentOS 6.4 box has glibc 2.12 installed. The Debian 7 box has glibc 2.13 installed.
What accounts for the different behavior between the two operating systems with regards to opening and reading /etc/resolv.conf?