Using -1 for invalid fds.
Fixing warnings.