… | |
… | |
152 | |
152 | |
153 | # now $master_filehandle is connected to the |
153 | # now $master_filehandle is connected to the |
154 | # $slave_filehandle in the new process. |
154 | # $slave_filehandle in the new process. |
155 | }); |
155 | }); |
156 | |
156 | |
157 | # MyModule::worker might look like this |
157 | MyModule::worker might look like this: |
|
|
158 | |
158 | sub MyModule::worker { |
159 | sub MyModule::worker { |
159 | my ($slave_filehandle) = @_; |
160 | my ($slave_filehandle) = @_; |
160 | |
161 | |
161 | # now $slave_filehandle is connected to the $master_filehandle |
162 | # now $slave_filehandle is connected to the $master_filehandle |
162 | # in the original prorcess. have fun! |
163 | # in the original prorcess. have fun! |
… | |
… | |
182 | } |
183 | } |
183 | |
184 | |
184 | # now do other things - maybe use the filehandle provided by run |
185 | # now do other things - maybe use the filehandle provided by run |
185 | # to wait for the processes to die. or whatever. |
186 | # to wait for the processes to die. or whatever. |
186 | |
187 | |
187 | # My::Server::run might look like this |
188 | My::Server::run might look like this: |
|
|
189 | |
188 | sub My::Server::run { |
190 | sub My::Server::run { |
189 | my ($slave, $listener, $id) = @_; |
191 | my ($slave, $listener, $id) = @_; |
190 | |
192 | |
191 | close $slave; # we do not use the socket, so close it to save resources |
193 | close $slave; # we do not use the socket, so close it to save resources |
192 | |
194 | |
… | |
… | |
560 | Normally, only processes created via C<< AnyEvent::Fork->new_exec >> and |
562 | Normally, only processes created via C<< AnyEvent::Fork->new_exec >> and |
561 | L<AnyEvent::Fork::Template> are direct children, and you are responsible |
563 | L<AnyEvent::Fork::Template> are direct children, and you are responsible |
562 | to clean up their zombies when they die. |
564 | to clean up their zombies when they die. |
563 | |
565 | |
564 | All other processes are not direct children, and will be cleaned up by |
566 | All other processes are not direct children, and will be cleaned up by |
565 | AnyEvent::Fork. |
567 | AnyEvent::Fork itself. |
566 | |
568 | |
567 | =cut |
569 | =cut |
568 | |
570 | |
569 | sub pid { |
571 | sub pid { |
570 | $_[0][0] |
572 | $_[0][0] |