how to create a file handle with using file descriptor in perl?

Chaofei

New member
open(INPUT, "< /etc/motd") or die "/etc/motd: $!";
if ($pid = fork) { wait }
else {
defined($pid) or die "fork:$!";
open(STDIN, "<&INPUT") or die "dup: $!";
exec("cat", "-n") or die "exec cat: $!";#or system(...);
}
i just want to pass a file handle into a parallel process.and how to pass a socket to a new process.
<unix networking programing v1> 2edition there is some detials about what i want in 14.7 in that book.
another way to do that is like this.
but i can't create a file handle with a file descriptor.it doesn't work in the new process.
if (defined($ENV{input_fdno}) && $ENV{input_fdno}) =~ /^\d$/) {
open(INPUT, "<&=$ENV{input_fdno}")
or die "can't fdopen $ENV{input_fdno} for input: $!";
}
 
Perl is a high-level language. Its "file handles" are complicated data structures that do NOT have meaning outside the Perl program and can NOT be transferred to other programs. Sorry!
 


Write your reply...
Back
Top