ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-FDPass/FDPass.pm
(Generate patch)

Comparing IO-FDPass/FDPass.pm (file contents):
Revision 1.4 by root, Fri Apr 5 08:20:36 2013 UTC vs.
Revision 1.7 by root, Sat Apr 6 22:10:56 2013 UTC

3IO::FDPass - pass a file descriptor over a socket 3IO::FDPass - pass a file descriptor over a socket
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use IO::FDPass; 7 use IO::FDPass;
8
9 IO::FDPass::send fileno $socket, fileno $fh_to_pass
10 or die "send failed: $!";
11
12 my $fd = IO::FDPass::recv fileno $socket;
13 $fd >= 0 or die "recv failed: $!";
8 14
9=head1 DESCRIPTION 15=head1 DESCRIPTION
10 16
11This small low-level module only has one purpose: pass a file descriptor 17This small low-level module only has one purpose: pass a file descriptor
12to another process, using a (streaming) unix domain socket (on POSIX 18to another process, using a (streaming) unix domain socket (on POSIX
77and higher). 83and higher).
78 84
79However, windows doesn't support asynchronous file descriptor passing, so 85However, windows doesn't support asynchronous file descriptor passing, so
80the source process must still be around when the destination process wants 86the source process must still be around when the destination process wants
81to receive the file handle. Also, if the target process fails to fetch the 87to receive the file handle. Also, if the target process fails to fetch the
82handle, the handle will leak, so never do that. 88handle for any reason (crashes, fails to call C<recv> etc.), the handle
89will leak, so never do that.
83 90
84Also, on windows, the receiving process must have the PROCESS_DUP_HANDLE 91Also, on windows, the receiving process must have the PROCESS_DUP_HANDLE
85access right on the sender process for this module to work. 92access right on the sender process for this module to work.
86 93
87Cygwin is not supported at the moment, as file descriptor passing in 94Cygwin is not supported at the moment, as file descriptor passing in
90one isn't exposed to programs, and only used for stdin/out/err. Sigh. 97one isn't exposed to programs, and only used for stdin/out/err. Sigh.
91 98
92=head1 OTHER MODULES 99=head1 OTHER MODULES
93 100
94At the time of this writing, the author of this module was aware of two 101At the time of this writing, the author of this module was aware of two
95other file descriptor passing modules on CPAN: L<Linux::FDPasser> and 102other file descriptor passing modules on CPAN: L<File::FDPasser> and
96L<AnyEvent::FDPasser>. 103L<AnyEvent::FDPasser>.
97 104
98The former hasn't seen any release for over a decade, isn't 64 bit clean 105The former hasn't seen any release for over a decade, isn't 64 bit clean
99and it's author didn't respond to my mail with the fix. It does, however, 106and it's author didn't respond to my mail with the fix, so doesn't work on
100support a snumber of pre-standard unices. 107many 64 bit machines. It does, however, support a number of pre-standard
108unices, basically everything of relevance at the time it was written.
101 109
102The latter seems to have similar support for antique unices, and doesn't 110The latter seems to have similar support for antique unices, and doesn't
103seem to suffer from 64 bit bugs, but inexplicably has a large perl part, 111seem to suffer from 64 bit bugs, but inexplicably has a large perl part,
104and requires AnyEvent. Presumably that makes it much more user friendly 112and requires AnyEvent. Presumably that makes it much more user friendly
105than this module. 113than this module (skimming the manpage shows that a lot of thought has
114gone into it, and you are well advised to read it and maybe use it before
115trying a low-level module such as this one).
106 116
107Neither seems to support native win32 perls. 117Neither seems to support native win32 perls.
108 118
109=head1 AUTHOR 119=head1 AUTHOR
110 120

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines