#!/usr/bin/env perl use strict; use warnings; use autodie; $| = 1; open my $in, '<', '/etc/passwd'; my $ppid = $$; unless (fork) { print "CHILD: "; exec ("grep", "root", "/proc/$ppid/fd/" . fileno($in)); } else { print "PARENT: still going\n"; wait; } close $in;