+my %path_to_fd = ('/dev/stdin' => 0, '/dev/stdout' => 1, '/dev/stderr' => 2);
+$path_to_fd{"/dev/fd/$_"} = $path_to_fd{"/proc/self/fd/$_"} for (0..2);
+sub fopen {
+ my ($self, $mode, $path) = @_;
+ rel2abs($self, $path);
+ $path =~ tr!/!/!s;
+ if (defined(my $fd = $path_to_fd{$path})) {
+ return $self->{$fd};
+ }
+ if ($path =~ m!\A/(?:dev|proc/self)/fd/[0-9]+\z!) {
+ return fail($self, "cannot open $path from daemon");
+ }
+ open my $fh, $mode, $path or return;
+ $fh;
+}
+