http://www.perlmonks.org?node_id=765232


in reply to Results printing multiple times when testcase with fork using Test::more module

Since you fork, you spawn another process from the current process and thus have two results. Why do you fork if you want just one run of the test?

If you want the child to terminate before the evaluation of the last ok() test, your sub should look like:

sub for{ my $pid = fork; if($pid == 0 ){ diag "$$: 0\n"; exit; }else{ diag "$$: 1\n"; waitpid($pid,0); } 1; }