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.2 by root, Fri Apr 5 04:26:41 2013 UTC vs.
Revision 1.5 by root, Fri Apr 5 09:12:59 2013 UTC

4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use IO::FDPass; 7 use IO::FDPass;
8 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: $!";
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 unix domain socket (on POSIX systems) or any 18to another process, using a (streaming) unix domain socket (on POSIX
13socket (on WIN32 systems). 19systems) or any (streaming) socket (on WIN32 systems).
14 20
15=head1 FUNCTIONS 21=head1 FUNCTIONS
16 22
17=over 4 23=over 4
18 24
19=cut 25=cut
20 26
21package IO::FDPass; 27package IO::FDPass;
22 28
23BEGIN { 29BEGIN {
24 $VERSION = '0.0'; 30 $VERSION = 0.2;
25 31
26 require XSLoader; 32 require XSLoader;
27 XSLoader::load (__PACKAGE__, $VERSION); 33 XSLoader::load (__PACKAGE__, $VERSION);
28} 34}
29 35
67 73
68=back 74=back
69 75
70=head1 PORTABILITY NOTES 76=head1 PORTABILITY NOTES
71 77
72This module has been tested on NetBSD 6, OS X 10.5, Windows 2000 78This module has been tested on GNU/Linux x86 and amd64, NetBSD 6, OS X
73ActivePerl 5.10, Solaris 10, OpenBSD 4.4, 4.5, 4.8 and 5.0, DragonFly 7910.5, Windows 2000 ActivePerl 5.10, Solaris 10, OpenBSD 4.4, 4.5, 4.8 and
74BSD, FreeBSD 7, 8 and 9, Windows 7 + ActivePerl 5.16.3 32 and 64 bit 805.0, DragonFly BSD, FreeBSD 7, 8 and 9, Windows 7 + ActivePerl 5.16.3 32
75and Strawberry Perl 5.16.3 32 and 64 bit, and found to work, although 81and 64 bit and Strawberry Perl 5.16.3 32 and 64 bit, and found to work,
76ActivePerl 32 bit needed a newer MinGW version (that supports XP and 82although ActivePerl 32 bit needed a newer MinGW version (that supports XP
77higher). 83and higher).
78 84
79However, windows doesn't support asynchronous file descriptor passing, so 85However, windows doesn't support asynchronous file descriptor passing, so
80C<send> and C<recv> will have to "rendezvous", that is, they have to wait 86the source process must still be around when the destination process wants
81for each other. Therefore, on windows, it's advisable to run them at the 87to receive the file handle. Also, if the target process fails to fetch the
82same time to avoid any unnecessary delays. 88handle, the handle will leak, so never do that.
83 89
84Also, on windows, the passing process must give the receiving process the 90Also, on windows, the receiving process must have the PROCESS_DUP_HANDLE
85PROCESS_DUP_HANDLE access right for this module to work. 91access right on the sender process for this module to work.
92
93Cygwin is not supported at the moment, as file descriptor passing in
94cygwin is not supported, and cannot be rolled on your own as cygwin has no
95(working) method of opening a handle as fd. That is, it has one, but that
96one isn't exposed to programs, and only used for stdin/out/err. Sigh.
86 97
87=head1 OTHER MODULES 98=head1 OTHER MODULES
88 99
89At the time of this writing, the author of this module was aware of two 100At the time of this writing, the author of this module was aware of two
90other file descriptor passing modules on CPAN: L<Linux::FDPasser> and 101other file descriptor passing modules on CPAN: L<Linux::FDPasser> and

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines