changeset 296:a113f4d55b12

Tests: fix hang on exit after errors in child processes. The f781b087b7aa moved test directory removal from File::Temp, where it was protected by a pid check, into Test::Nginx destructor. As a result destruction triggered due to a child process death now removes temp directory, thus preventing main process from stopping nginx as it no longer able to read nginx.pid. Fix is to protect destructor with pid check.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 08 Jun 2013 07:12:31 +0400
parents 6fe0459b6668
children 389cee4c78aa
files lib/Test/Nginx.pm
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -35,6 +35,8 @@ sub new {
 	my $self = {};
 	bless $self;
 
+	$self->{_pid} = $$;
+
 	$self->{_testdir} = tempdir(
 		'nginx-test-XXXXXXXXXX',
 		TMPDIR => 1
@@ -47,6 +49,7 @@ sub new {
 
 sub DESTROY {
 	my ($self) = @_;
+	return if $self->{_pid} != $$;
 	$self->stop();
 	$self->stop_daemons();
 	if ($ENV{TEST_NGINX_CATLOG}) {