ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-Fork/Fork.pm
(Generate patch)

Comparing cvsroot/AnyEvent-Fork/Fork.pm (file contents):
Revision 1.6 by root, Wed Apr 3 08:47:44 2013 UTC vs.
Revision 1.7 by root, Thu Apr 4 00:27:06 2013 UTC

228} 228}
229 229
230# fork template from current process, used by AnyEvent::Fork::Early/Template 230# fork template from current process, used by AnyEvent::Fork::Early/Template
231sub _new_fork { 231sub _new_fork {
232 my ($fh, $slave) = AnyEvent::Util::portable_socketpair; 232 my ($fh, $slave) = AnyEvent::Util::portable_socketpair;
233 my $parent = $$;
234
233 my $pid = fork; 235 my $pid = fork;
234 236
235 if ($pid eq 0) { 237 if ($pid eq 0) {
236 require AnyEvent::Fork::Serve; 238 require AnyEvent::Fork::Serve;
239 $AnyEvent::Fork::Serve::OWNER = $parent;
237 close $fh; 240 close $fh;
241 $0 = "$_[1] of $parent";
238 AnyEvent::Fork::Serve::serve ($slave); 242 AnyEvent::Fork::Serve::serve ($slave);
239 AnyEvent::Fork::Util::_exit 0; 243 AnyEvent::Fork::Util::_exit 0;
240 } elsif (!$pid) { 244 } elsif (!$pid) {
241 die "AnyEvent::Fork::Early/Template: unable to fork template process: $!"; 245 die "AnyEvent::Fork::Early/Template: unable to fork template process: $!";
242 } 246 }
335 my %env = %ENV; 339 my %env = %ENV;
336 $env{PERL5LIB} = join ":", grep !ref, @INC; 340 $env{PERL5LIB} = join ":", grep !ref, @INC;
337 341
338 Proc::FastSpawn::spawn ( 342 Proc::FastSpawn::spawn (
339 $perl, 343 $perl,
340 ["perl", "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave], 344 ["perl", "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave, $$],
341 [map "$_=$env{$_}", keys %env], 345 [map "$_=$env{$_}", keys %env],
342 ) or die "unable to spawn AnyEvent::Fork server: $!"; 346 ) or die "unable to spawn AnyEvent::Fork server: $!";
343 347
344 $self->_new ($fh) 348 $self->_new ($fh)
345} 349}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines