File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -177,26 +177,6 @@ sub parent
177177 return ($self->{HANDLE}{TOOLS});
178178}
179179
180- sub DESTROY
181- {
182- my $self = shift;
183-
184- my $listeners = $self->{listeners};
185-
186- # Clean up all lingering database listeners
187- foreach my $forks (values %{$listeners})
188- {
189- foreach my $fork (values %{$forks})
190- {
191- next if not $fork->poll();
192-
193- print "Database listener with PID: [".$fork->pid."] exiting on DESTROY.\n";
194-
195- $fork->kill() or $fork->kill("SIGKILL");
196- }
197- }
198- }
199-
200180
201181#############################################################################################################
202182# Public methods #
@@ -242,6 +222,11 @@ sub add_listener
242222
243223 my $listener = Proc::Simple->new();
244224
225+ # The reference of all listeners are stored in $self->{listeners}, which will be removed on DESTROY of $self.
226+ #
227+ # Set the flag to kill the listener when all references to it are removed.
228+ $listener->kill_on_destroy(1);
229+
245230 my $forked = $listener->start(\&run_listener, $self, $parameters);
246231
247232 if (not $forked)
You can’t perform that action at this time.
0 commit comments