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

Comparing AnyEvent-Fork/Fork.pm (file contents):
Revision 1.43 by root, Thu Apr 18 10:47:48 2013 UTC vs.
Revision 1.46 by root, Thu Apr 18 11:18:23 2013 UTC

224 } 224 }
225 } 225 }
226 226
227=head2 use AnyEvent::Fork as a faster fork+exec 227=head2 use AnyEvent::Fork as a faster fork+exec
228 228
229This runs C</bin/echo hi>, with stdandard output redirected to /tmp/log 229This runs C</bin/echo hi>, with standard output redirected to F</tmp/log>
230and standard error redirected to the communications socket. It is usually 230and standard error redirected to the communications socket. It is usually
231faster than fork+exec, but still lets you prepare the environment. 231faster than fork+exec, but still lets you prepare the environment.
232 232
233 open my $output, ">/tmp/log" or die "$!"; 233 open my $output, ">/tmp/log" or die "$!";
234 234
254 254
255=head1 CONCEPTS 255=head1 CONCEPTS
256 256
257This module can create new processes either by executing a new perl 257This module can create new processes either by executing a new perl
258process, or by forking from an existing "template" process. 258process, or by forking from an existing "template" process.
259
260All these processes are called "child processes" (whether they are direct
261children or not), while the process that manages them is called the
262"parent process".
259 263
260Each such process comes with its own file handle that can be used to 264Each such process comes with its own file handle that can be used to
261communicate with it (it's actually a socket - one end in the new process, 265communicate with it (it's actually a socket - one end in the new process,
262one end in the main process), and among the things you can do in it are 266one end in the main process), and among the things you can do in it are
263load modules, fork new processes, send file handles to it, and execute 267load modules, fork new processes, send file handles to it, and execute
595 $_[0][PID] 599 $_[0][PID]
596} 600}
597 601
598=item $proc = $proc->eval ($perlcode, @args) 602=item $proc = $proc->eval ($perlcode, @args)
599 603
600Evaluates the given C<$perlcode> as ... perl code, while setting C<@_> to 604Evaluates the given C<$perlcode> as ... Perl code, while setting C<@_> to
601the strings specified by C<@args>, in the "main" package. 605the strings specified by C<@args>, in the "main" package.
602 606
603This call is meant to do any custom initialisation that might be required 607This call is meant to do any custom initialisation that might be required
604(for example, the C<require> method uses it). It's not supposed to be used 608(for example, the C<require> method uses it). It's not supposed to be used
605to completely take over the process, use C<run> for that. 609to completely take over the process, use C<run> for that.
871initialising them, for example, by calling C<init Gtk2> manually. 875initialising them, for example, by calling C<init Gtk2> manually.
872 876
873=item exiting calls object destructors 877=item exiting calls object destructors
874 878
875This only applies to users of L<AnyEvent::Fork:Early> and 879This only applies to users of L<AnyEvent::Fork:Early> and
876L<AnyEvent::Fork::Template>, or when initialiasing code creates objects 880L<AnyEvent::Fork::Template>, or when initialising code creates objects
877that reference external resources. 881that reference external resources.
878 882
879When a process created by AnyEvent::Fork exits, it might do so by calling 883When a process created by AnyEvent::Fork exits, it might do so by calling
880exit, or simply letting perl reach the end of the program. At which point 884exit, or simply letting perl reach the end of the program. At which point
881Perl runs all destructors. 885Perl runs all destructors.
906Cygwin perl is not supported at the moment due to some hilarious 910Cygwin perl is not supported at the moment due to some hilarious
907shortcomings of its API - see L<IO::FDPoll> for more details. 911shortcomings of its API - see L<IO::FDPoll> for more details.
908 912
909=head1 SEE ALSO 913=head1 SEE ALSO
910 914
911L<AnyEvent::Fork::Early> (to avoid executing a perl interpreter), 915L<AnyEvent::Fork::Early>, to avoid executing a perl interpreter at all
916(part of this distribution).
917
912L<AnyEvent::Fork::Template> (to create a process by forking the main 918L<AnyEvent::Fork::Template>, to create a process by forking the main
913program at a convenient time). 919program at a convenient time (part of this distribution).
920
921L<AnyEvent::Fork::RPC>, for simple RPC to child processes (on CPAN).
914 922
915=head1 AUTHOR AND CONTACT INFORMATION 923=head1 AUTHOR AND CONTACT INFORMATION
916 924
917 Marc Lehmann <schmorp@schmorp.de> 925 Marc Lehmann <schmorp@schmorp.de>
918 http://software.schmorp.de/pkg/AnyEvent-Fork 926 http://software.schmorp.de/pkg/AnyEvent-Fork

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines