in reply to working with files by number
if(fork()){ #read }else{ my $so_fd=fileno($w_stdout); my $se_fd=fileno($w_stderr); my $si_fd=fileno($r_stdin); # # fd3 must be $w_fd3, so backup current fd3, and reopen 3 to $w_fd3 # my $old3=dup(3); my $new3=dup2(fileno($w_fd3), 3); # # then if any of the other fd's we were going to use was 3, change it +to the backup fd # for my $i ($so_fd, $se_fd, $si_fd){ if ($i == 3){ $i=$old3; } } open STDOUT, ">&$so_fd"; open STDERR, ">&$se_fd"; open STDIN, "<&$si_fd";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: working with files by number
by ikegami (Patriarch) on Mar 24, 2009 at 16:53 UTC |