Use pipe2() instead of socketpair()

Socketpair isn't required as there's only communication between the
main thread and each I/O thread.