@@ -13,6 +13,7 @@ my $sock = IO::Socket::INET->new(
1313 ReuseAddr => 1,
1414);
1515
16+ # should be in 100_flush_bug-win32.pl too
1617my @res = (
1718 [" OK\r\n " , 1],
1819 [" ERROR\r\n " , 0],
@@ -31,24 +32,36 @@ if ($sock) {
3132}
3233close $sock ;
3334
34- my $pid = fork ;
35- die " Cannot fork because: '$! '" unless defined $pid ;
36- unless ($pid ) {
37-
38- my $sock = IO::Socket::INET-> new(
39- LocalAddr => $testaddr ,
40- Proto => ' tcp' ,
41- ReuseAddr => 1,
42- Listen => 1,
43- ) or die " cannot open $testaddr : $! " ;
44- my $csock = $sock -> accept();
45- while (defined (my $buf = <$csock >)) {
46- my $res = shift @res ;
47- print $csock $res -> [0];
35+ my $processobj ;
36+ if ($^O eq ' MSWin32' ) {
37+ require Win32::Process;
38+ Win32::Process::Create($processobj ,
39+ " $^X" ,
40+ " $^X t/100_flush_bug-win32.pl $testaddr " ,
41+ 0,
42+ 32 + 134217728, # NORMAL_PRIORITY_CLASS + CREATE_NO_WINDOW
43+ " ." ) || die $^E;
44+
45+ } else {
46+ my $pid = fork ;
47+ die " Cannot fork because: '$! '" unless defined $pid ;
48+ unless ($pid ) {
49+
50+ my $sock = IO::Socket::INET-> new(
51+ LocalAddr => $testaddr ,
52+ Proto => ' tcp' ,
53+ ReuseAddr => 1,
54+ Listen => 1,
55+ ) or die " cannot open $testaddr : $! " ;
56+ my $csock = $sock -> accept();
57+ while (defined (my $buf = <$csock >)) {
58+ my $res = shift @res ;
59+ print $csock $res -> [0];
60+ }
61+ close $csock ;
62+ close $sock ;
63+ exit 0;
4864 }
49- close $csock ;
50- close $sock ;
51- exit 0;
5265}
5366
5467# give the forked server a chance to startup
@@ -60,3 +73,7 @@ for (@res) {
6073 ($_ -> [0] =~ s /\W // g );
6174 is $memd -> flush_all, $_ -> [1], $_ -> [0];
6275}
76+
77+ if ($processobj ) {
78+ $processobj -> Wait(1000) or $processobj -> Kill(0);
79+ }
0 commit comments