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

Comparing Proc-FastSpawn/FastSpawn.pm (file contents):
Revision 1.1 by root, Fri Mar 29 22:15:52 2013 UTC vs.
Revision 1.4 by root, Thu Apr 4 08:00:38 2013 UTC

2 2
3Proc::FastSpawn - fork+exec, or spawn, a subprocess as quickly as possible 3Proc::FastSpawn - fork+exec, or spawn, a subprocess as quickly as possible
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use Proc::FastSpawn; 7 use Proc::FastSpawn;
8
9 # simple use
10 my $pid = spawn "/bin/echo", ["echo", "hello, world"];
11 ...
12 waitpid $pid, 0;
13
14 # with environment
15 my $pid = spawn "/bin/echo", ["echo", "hello, world"], ["PATH=/bin", "HOME=/tmp"];
16
17 # inheriting file descriptors
18 pipe R, W or die;
19 fd_inherit fileno W;
20 my $pid = spawn "/bin/sh", ["sh", "-c", "echo a pipe >&" . fileno W];
21 close W;
22 print <R>;
8 23
9=head1 DESCRIPTION 24=head1 DESCRIPTION
10 25
11The purpose of this small (in scope and footprint) module is simple: 26The purpose of this small (in scope and footprint) module is simple:
12spawn a subprocess asynchronously as efficiently and/or fast as 27spawn a subprocess asynchronously as efficiently and/or fast as
66 } 81 }
67 } 82 }
68} 83}
69 84
70BEGIN { 85BEGIN {
71 $VERSION = '0.1'; 86 $VERSION = '0.2';
72 87
73 our @ISA = qw(Exporter); 88 our @ISA = qw(Exporter);
74 our @EXPORT = qw(spawn fd_inherit); 89 our @EXPORT = qw(spawn fd_inherit);
75 require Exporter; 90 require Exporter;
76 91
94decided on a per file descriptor basis. This module does nothing to any 109decided on a per file descriptor basis. This module does nothing to any
95preexisting handles, but with this call, you can change the state of a 110preexisting handles, but with this call, you can change the state of a
96single file descriptor to either be inherited (C<$on> is true or missing) 111single file descriptor to either be inherited (C<$on> is true or missing)
97or not C<$on> is false). 112or not C<$on> is false).
98 113
114Free portability pro-tip: it seems native win32 perls ignore $^F and set
115all file handles to be inherited by default - but this fucntino can switch
116it off.
117
99=back 118=back
100 119
101=head1 PORTABILITY NOTES 120=head1 PORTABILITY NOTES
102 121
103On POSIX systems, this module currently calls vfork+exec, spawn, or 122On POSIX systems, this module currently calls vfork+exec, spawn, or
104fork+exec, depending on the platform. If your platform has a good vfork or 123fork+exec, depending on the platform. If your platform has a good vfork or
105spawn but is misdetected and falls back on slow fork+exec, drop me a note. 124spawn but is misdetected and falls back to slow fork+exec, drop me a note.
106 125
107On win32, the C<_spawn> family of functions is used, and the module tries 126On win32, the C<_spawn> family of functions is used, and the module tries
108hard to patch the new process into perl's internal pid table, so the pid 127hard to patch the new process into perl's internal pid table, so the pid
109returned should work with other perl functions such as waitpid. Also, 128returned should work with other perl functions such as waitpid. Also,
110win32 doesn't have a meaningful way to quote arguments containing 129win32 doesn't have a meaningful way to quote arguments containing
111"special" characters, so this module tries it's best to quote those 130"special" characters, so this module tries it's best to quote those
112strings itself. Other typical platform limitations (such as being able to 131strings itself. Other typical platform limitations (such as being able to
113only have 64 or so subprocesses) apply as well. 132only have 64 or so subprocesses) are not worked around.
114 133
115=head1 AUTHOR 134=head1 AUTHOR
116 135
117 Marc Lehmann <schmorp@schmorp.de> 136 Marc Lehmann <schmorp@schmorp.de>
118 http://home.schmorp.de/ 137 http://home.schmorp.de/
119 138
120=cut 139=cut
121 140
1221; 1411
123 142

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines