replace hard-code 2 with fileno(stderr)
open("/dev/stderr") instead of fileno(stderr).Under fcgi env,stderr may be a socket.