ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Async-Interrupt/t/02_pipe.t
Revision: 1.3
Committed: Sat Jul 11 22:16:50 2009 UTC (15 years ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_042, rel-0_041, rel-1_25, rel-1_22, rel-0_5, rel-1_23, rel-1_1, rel-1_0, rel-0_501, rel-1_2, rel-1_02, rel-1_03, rel-1_01, rel-1_04, rel-1_05, rel-1_24, rel-0_04, rel-1_26, rel-0_06, rel-1_21, HEAD
Changes since 1.2: +12 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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 root 1.3 print "1..12\n"; $|=1;
15 root 1.1
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";
47 root 1.3
48     $ai->pipe_disable;
49     $ai->scope_block;
50    
51     $ai->signal (12);
52    
53     my $n = select $vR=$vr, undef, undef, 0;
54     print $n == 0 ? "" : "not ", "ok 11 # $n\n";
55    
56     undef $ai; # will cause signal to be sent
57