You should do something like this here instead: https://github.com/joyent/libuv/blob/master/src/unix/stream.c#L430