Thursday, October 18, 2012

Chasing after fd 5


On FreeBSD 9, the mod_cgid daemon appears to have an odd file open, and in my current configuration that is file descriptor 5. procstat displays it as

26889 httpd               5 ? - ---------   2       0 -

The question mark is the result of translating unknown through multiple namespaces, and I stopped chasing it through the code backwards when I saw libprocstat copying foo_UNKNOWN to bar_UNKNOWN.

The file descriptor isn't really in use, since a CGI request will result in accept() returning 5 in that process.

Using DTrace to print the syscall name and pid for every syscall issued by httpd with either first arg 5 or return value 5 shows that it is a listening socket created in the initial httpd process and closed by the mod_cgid daemon, presumably via a call to ap_close_listeners().

There may be an interesting story/bug behind this, but I don't think it is in httpd-land, and time is flying.

#!/usr/sbin/dtrace -s

syscall:::entry
/execname == "httpd" && arg0 == 5/
{
  printf("%s %d %d\n", probefunc, arg0, pid);
}

syscall:::return
/execname == "httpd" && arg0 == 5/
{
  printf("%s %d %d\n", probefunc, arg0, pid);
}

(No, ustack() isn't working for me, but I didn't make world with the suggested flags.)

No comments: