… | |
… | |
465 | use AnyEvent; |
465 | use AnyEvent; |
466 | use AnyEvent::Util (); |
466 | use AnyEvent::Util (); |
467 | |
467 | |
468 | use IO::FDPass; |
468 | use IO::FDPass; |
469 | |
469 | |
470 | our $VERSION = 1.2; |
470 | our $VERSION = 1.31; |
471 | |
471 | |
472 | # the early fork template process |
472 | # the early fork template process |
473 | our $EARLY; |
473 | our $EARLY; |
474 | |
474 | |
475 | # the empty template process |
475 | # the empty template process |
… | |
… | |
556 | |
556 | |
557 | if ($pid eq 0) { |
557 | if ($pid eq 0) { |
558 | require AnyEvent::Fork::Serve; |
558 | require AnyEvent::Fork::Serve; |
559 | $AnyEvent::Fork::Serve::OWNER = $parent; |
559 | $AnyEvent::Fork::Serve::OWNER = $parent; |
560 | close $fh; |
560 | close $fh; |
561 | $0 = "$_[1] of $parent"; |
561 | $0 = "$parent AnyEvent::Fork/exec"; |
562 | AnyEvent::Fork::Serve::serve ($slave); |
562 | AnyEvent::Fork::Serve::serve ($slave); |
563 | exit 0; |
563 | exit 0; |
564 | } elsif (!$pid) { |
564 | } elsif (!$pid) { |
565 | die "AnyEvent::Fork::Early/Template: unable to fork template process: $!"; |
565 | die "AnyEvent::Fork::Early/Template: unable to fork template process: $!"; |
566 | } |
566 | } |
… | |
… | |
624 | The path to the perl interpreter is divined using various methods - first |
624 | The path to the perl interpreter is divined using various methods - first |
625 | C<$^X> is investigated to see if the path ends with something that looks |
625 | C<$^X> is investigated to see if the path ends with something that looks |
626 | as if it were the perl interpreter. Failing this, the module falls back to |
626 | as if it were the perl interpreter. Failing this, the module falls back to |
627 | using C<$Config::Config{perlpath}>. |
627 | using C<$Config::Config{perlpath}>. |
628 | |
628 | |
629 | The path to perl can also be overriden by setting the global variable |
629 | The path to perl can also be overridden by setting the global variable |
630 | C<$AnyEvent::Fork::PERL> - it's value will be used for all subsequent |
630 | C<$AnyEvent::Fork::PERL> - it's value will be used for all subsequent |
631 | invocations. |
631 | invocations. |
632 | |
632 | |
633 | =cut |
633 | =cut |
634 | |
634 | |
… | |
… | |
673 | my %env = %ENV; |
673 | my %env = %ENV; |
674 | $env{PERL5LIB} = join +($^O eq "MSWin32" ? ";" : ":"), grep !ref, @INC; |
674 | $env{PERL5LIB} = join +($^O eq "MSWin32" ? ";" : ":"), grep !ref, @INC; |
675 | |
675 | |
676 | my $pid = Proc::FastSpawn::spawn ( |
676 | my $pid = Proc::FastSpawn::spawn ( |
677 | $PERL, |
677 | $PERL, |
678 | ["perl", "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave, $$], |
678 | [$PERL, "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave, $$], |
679 | [map "$_=$env{$_}", keys %env], |
679 | [map "$_=$env{$_}", keys %env], |
680 | ) or die "unable to spawn AnyEvent::Fork server: $!"; |
680 | ) or die "unable to spawn AnyEvent::Fork server: $!"; |
681 | |
681 | |
682 | $self->_new ($fh, $pid) |
682 | $self->_new ($fh, $pid) |
683 | } |
683 | } |
… | |
… | |
907 | $self->_cmd (r => $func); |
907 | $self->_cmd (r => $func); |
908 | } |
908 | } |
909 | |
909 | |
910 | =back |
910 | =back |
911 | |
911 | |
|
|
912 | |
|
|
913 | =head2 CHILD PROCESS INTERFACE |
|
|
914 | |
|
|
915 | This module has a limited API for use in child processes. |
|
|
916 | |
|
|
917 | =over 4 |
|
|
918 | |
|
|
919 | =item @args = AnyEvent::Fork::Serve::run_args |
|
|
920 | |
|
|
921 | This function, which only exists before the C<run> method is called, |
|
|
922 | returns the arguments that would be passed to the run function, and clears |
|
|
923 | them. |
|
|
924 | |
|
|
925 | This is mainly useful to get any file handles passed via C<send_fh>, but |
|
|
926 | works for any arguments passed via C<< send_I<xxx> >> methods. |
|
|
927 | |
|
|
928 | =back |
|
|
929 | |
|
|
930 | |
912 | =head2 EXPERIMENTAL METHODS |
931 | =head2 EXPERIMENTAL METHODS |
913 | |
932 | |
914 | These methods might go away completely or change behaviour, at any time. |
933 | These methods might go away completely or change behaviour, at any time. |
915 | |
934 | |
916 | =over 4 |
935 | =over 4 |