Use pipe2() with O_CLOEXEC where available