From 909240c0c13774ef8ed4fb0c2abb755018de8f9c Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 8 Sep 2010 16:24:25 -0500 Subject: [PATCH] fork instead of running a subprocess for Mail tests --- t/lib/WebGUI/Test/MailServer.pm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/t/lib/WebGUI/Test/MailServer.pm b/t/lib/WebGUI/Test/MailServer.pm index 6021e8cf6..2b199d629 100644 --- a/t/lib/WebGUI/Test/MailServer.pm +++ b/t/lib/WebGUI/Test/MailServer.pm @@ -52,14 +52,13 @@ use strict; use warnings; use JSON (); -use File::Spec::Functions qw(catdir updir); -use File::Basename qw(dirname); use IO::Select; use Net::SMTP::Server; use Net::SMTP::Server::Client; use MIME::Parser; use Scope::Guard; use MIME::Parser; +use POSIX (); my $smtpdPid; my $smtpdStream; @@ -94,15 +93,18 @@ sub _setup_server { my $host = 'localhost'; my $port = 54921; - # make sure the lib path for this file is available - my $lib_path = catdir( dirname(__FILE__), (updir) x 2 ); - my @command_line = ( - $^X, "-I$lib_path", '-M' . __PACKAGE__, - '-e' . __PACKAGE__ . '::_run_server(@ARGV)', $host, $port, - ); - - $smtpdPid = open $smtpdStream, '-|', @command_line - or die "Could not open pipe to SMTPD: $!"; + $smtpdPid = open $smtpdStream, '-|'; + if ( ! defined $smtpdPid ) { + die "Could not open pipe to SMTPD: $!"; + } + # child + elsif ( ! $smtpdPid ) { + $SIG{INT} = sub { + POSIX::_exit(0); + }; + _run_server($host, $port); + POSIX::_exit(0); + } die "Could not open pipe to SMTPD: $!" unless $smtpdStream;