ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Async-Interrupt/t/02_pipe.t
Revision: 1.1
Committed: Thu Jul 2 15:13:03 2009 UTC (15 years ago) by root
Content type: application/x-troff
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# Content
1 #! perl
2
3 no warnings;
4
5 use Socket;
6
7 my ($pr, $pw);
8
9 unless (socketpair $pr, $pw, Socket::AF_UNIX (), Socket::SOCK_STREAM (), 0) {
10 print "1..0 # SKIP socketpair failed - broken platform, skipping tests\n";
11 exit;
12 }
13
14 print "1..10\n";
15
16 use Async::Interrupt;
17
18 # we ignore the requirement to put handles into nonblocking mode
19 # IN THIS TEST only. never do that in real life.
20 my $ai = new Async::Interrupt
21 pipe => [$pr, $pw],
22 cb => sub { print "ok $_[0]\n" };
23
24 print "ok 1\n";
25 $ai->signal (2);
26 print "ok 3\n";
27
28 my ($vr, $vR); vec ($vr, fileno $pr, 1) = 1;
29
30 my $n = select $vR=$vr, undef, undef, 0;
31 print $n == 0 ? "" : "not ", "ok 4 # $n\n";
32
33 $ai->block;
34 $ai->signal (7);
35 print "ok 5\n";
36 my $n = select $vR=$vr, undef, undef, 0;
37 print $n == 1 ? "" : "not ", "ok 6 # $n\n";
38 $ai->unblock;
39
40 my $n = select $vR=$vr, undef, undef, 0;
41 print $n == 0 ? "" : "not ", "ok 8 # $n\n";
42
43 $ai->signal (9);
44
45 my $n = select $vR=$vr, undef, undef, 0;
46 print $n == 0 ? "" : "not ", "ok 10 # $n\n";