Handle POLLHUP event after POLLIN and POLLPRI.
Use nonblocking read loop after POLLIN and POLLPRI events.
Use list instead of counter to keep track of processes stdin and stdout.
Unregister descriptors from poll instance on POLLHUP.