perl -we 'use warnings; use strict; use 5.010; use IO "Socket"; use Socket; use Fcntl; my($L, $R) = IO::Socket->socketpair(PF_UNIX, SOCK_STREAM, 0) or die; $L->fcntl(F_SETFD, $L->fcntl(F_GETFD, 0) &~ FD_CLOEXEC); defined(my $p = fork) or die "fork"; if (!$p) { exec @ARGV, $L->fileno; die "exec"; } $L->close; print "reading... "; my $x = $R->getline; say "got: $x"; 0 < waitpid $p,0 or die "wait";' perl -we 'use warnings; use strict; use 5.010; use IO::Socket; sleep 1; my $h = shift; say "fileno: $h"; my $O = IO::Socket->new_from_fd($h, ">") or die "fdopen $!"; $O->printflush("hello"); $O->shutdown(SHUT_WR); say "written"; sleep 1; say "done";'