The underlying file descriptor itself may be shared
But not even for file descriptors does the sharing extend to the point that opening (or even closing) the FD in one process will cause the same effect on a copy of it in some related process.
The most interesting part of the sharing (to me) is that seek() offsets are shared.
$ cat kidseek #!/usr/bin/perl -w use strict; $| = 1; print "One\nTwo\nThree\n"; if( ! fork() ) { seek( STDOUT, 4, 0 ) or die "Can't seek STDOUT in child: $!\n"; print "Kid"; seek( STDOUT, 0, 0 ) or die "Can't again seek STDOUT in child: $!\n"; exit; } wait(); print "Dad"; $ ./kidseek >kidseek.txt $ cat kidseek.txt Dad Kid Three $
- tye
In reply to Re^2: Filehandle reference lost between parent and child (fd)
by tye
in thread Filehandle reference lost between parent and child
by italdesign
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |