File: hup.t

package info (click to toggle)
libevent-perl 1.28-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 776 kB
  • sloc: ansic: 3,035; perl: 1,122; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 686 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
32
33
34
35
36
37
38
39
#!./perl -w

BEGIN {
    if ($^O eq 'MSWin32') {
	print "1..0 # skipped; Win32 is too strange\n";
	exit;
    }
}

# contributed by Gisle Aas <aas@gaustad.sys.sol.no>

use Test; plan test => 1;
use Event qw(loop unloop);

$| = 1;
my $pid = open(PIPE, "-|");
die unless defined $pid;
unless ($pid) {
    # child
    for (1..100) { print "."; }
    print "\n";
    exit;
}

my $bytes = 0;
Event->io(poll => "r",
          fd   => \*PIPE,
          cb   => sub {
             my $e = shift;
	     my $buf;
             my $n = sysread(PIPE, $buf, 10);
             $bytes += $n;
             #print "Got $n bytes\n";
             unloop() unless $n;
          });

loop();

ok $bytes, 101;