Add missing va_list definition for gcc48/FreeBSD.
Fix kqueue compile error for gcc48/FreeBSD.

Fix warnings of "missing return" and "unused param".
Add missing header file (unistd.h) for close().