applog: update the permission bit defines

S_IREAD, S_IWRITE (and S_IEXEC) are deprecated per
http://www.gnu.org/s/hello/manual/libc/Permission-Bits.html
serial: use ioctl() directly

tcdrain() is not available on Android.
file: add a lockf() replacement
configure: check for pthread_attr_setinheritsched()

Rely on default thread inheritance when not found.
configure: check for endgrent()