Stealing more great stuff from src/pkg/net/fd_* to watch file descriptors.