File: waitpid_blocking.t

package info (click to toggle)
libparallel-forkmanager-perl 2.04-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: perl: 479; xml: 297; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 424 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use strict;
use warnings;

use Test::More tests => 1;

use Parallel::ForkManager;

my $pm = Parallel::ForkManager->new(2);

$pm->set_waitpid_blocking_sleep(5);
my $start = time;

for(1) {
    $pm->start and last;
    sleep 1;
    $pm->finish;
}

$pm->wait_one_child;

# if the sleep works correctly, we shouldn't
# check if the child is gone before 5 seconds
# in the future

cmp_ok abs( 5 - time + $start ), '<=', 2;