… | |
… | |
11 | EOF |
11 | EOF |
12 | exit 0; |
12 | exit 0; |
13 | } |
13 | } |
14 | } |
14 | } |
15 | } |
15 | } |
|
|
16 | |
|
|
17 | $^W = 0; # 5.8.6 bugs |
16 | |
18 | |
17 | use AnyEvent; |
19 | use AnyEvent; |
18 | use AnyEvent::Util; |
20 | use AnyEvent::Util; |
19 | BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} } |
21 | BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} } |
20 | |
22 | |
… | |
… | |
39 | } |
41 | } |
40 | |
42 | |
41 | # I/O read |
43 | # I/O read |
42 | { |
44 | { |
43 | my $cv = AE::cv; |
45 | my $cv = AE::cv; |
44 | my $wt = AE::timer 0.1, 0, $cv; |
46 | my $wt = AE::timer 0.01, 0, $cv; |
45 | my $s = 0; |
47 | my $s = 0; |
46 | |
48 | |
47 | my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; |
49 | my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; |
48 | my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; |
50 | my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; |
49 | |
51 | |
… | |
… | |
64 | print $s == 3 ? "" : "not ", "ok 4 # $s\n"; |
66 | print $s == 3 ? "" : "not ", "ok 4 # $s\n"; |
65 | |
67 | |
66 | sysread $a, my $dummy, 1; |
68 | sysread $a, my $dummy, 1; |
67 | |
69 | |
68 | $cv = AE::cv; |
70 | $cv = AE::cv; |
69 | $wt = AE::timer 0.1, 0, $cv; |
71 | $wt = AE::timer 0.01, 0, $cv; |
70 | |
72 | |
71 | $s = 0; |
73 | $s = 0; |
72 | $cv->recv; |
74 | $cv->recv; |
73 | |
75 | |
74 | print $s == 0 ? "" : "not ", "ok 5 # $s\n"; |
76 | print $s == 0 ? "" : "not ", "ok 5 # $s\n"; |
75 | } |
77 | } |
76 | |
78 | |
77 | # signal |
79 | # signal |
78 | { |
80 | { |
79 | my $cv = AE::cv; |
81 | my $cv = AE::cv; |
80 | my $wt = AE::timer 0.1, 0, $cv; |
82 | my $wt = AE::timer 0.01, 0, $cv; |
81 | my $s = 0; |
83 | my $s = 0; |
82 | |
84 | |
83 | $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; |
85 | $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; |
84 | $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; |
86 | $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; |
85 | |
87 | |
… | |
… | |
88 | print $s == 0 ? "" : "not ", "ok 6 # $s\n"; |
90 | print $s == 0 ? "" : "not ", "ok 6 # $s\n"; |
89 | |
91 | |
90 | kill INT => $$; |
92 | kill INT => $$; |
91 | |
93 | |
92 | $cv = AE::cv; |
94 | $cv = AE::cv; |
93 | $wt = AE::timer 0.1, 0, $cv; |
95 | $wt = AE::timer 0.2, 0, $cv; # maybe OS X needs more time here? |
94 | |
96 | |
95 | $s = 0; |
97 | $s = 0; |
96 | $cv->recv; |
98 | $cv->recv; |
97 | |
99 | |
98 | print $s == 3 ? "" : "not ", "ok 7 # $s\n"; |
100 | print $s == 3 ? "" : "not ", "ok 7 # $s\n"; |
99 | |
101 | |
100 | $cv = AE::cv; |
102 | $cv = AE::cv; |
101 | $wt = AE::timer 0.1, 0, $cv; |
103 | $wt = AE::timer 0.01, 0, $cv; |
102 | |
104 | |
103 | $s = 0; |
105 | $s = 0; |
104 | $cv->recv; |
106 | $cv->recv; |
105 | |
107 | |
106 | print $s == 0 ? "" : "not ", "ok 8 # $s\n"; |
108 | print $s == 0 ? "" : "not ", "ok 8 # $s\n"; |
… | |
… | |
109 | $AnyEvent::MAX_SIGNAL_LATENCY = 0.2; |
111 | $AnyEvent::MAX_SIGNAL_LATENCY = 0.2; |
110 | |
112 | |
111 | # child |
113 | # child |
112 | { |
114 | { |
113 | my $cv = AE::cv; |
115 | my $cv = AE::cv; |
114 | my $wt = AE::timer 0.1, 0, $cv; |
116 | my $wt = AE::timer 0.01, 0, $cv; |
115 | my $s = 0; |
117 | my $s = 0; |
116 | |
118 | |
117 | my $pid = fork; |
119 | my $pid = fork; |
118 | |
120 | |
119 | unless ($pid) { |
121 | unless ($pid) { |
… | |
… | |
131 | print $s == 0 ? "" : "not ", "ok 9 # $s\n"; |
133 | print $s == 0 ? "" : "not ", "ok 9 # $s\n"; |
132 | |
134 | |
133 | kill 9, $pid; |
135 | kill 9, $pid; |
134 | |
136 | |
135 | $cv = AE::cv; |
137 | $cv = AE::cv; |
136 | $wt = AE::timer 0.1, 0, $cv; |
138 | $wt = AE::timer 0.2, 0, $cv; # cygwin needs ages for this |
137 | |
139 | |
138 | $s = 0; |
140 | $s = 0; |
139 | $cv->recv; |
141 | $cv->recv; |
140 | |
142 | |
141 | print $s == 3 ? "" : "not ", "ok 10 # $s\n"; |
143 | print $s == 3 ? "" : "not ", "ok 10 # $s\n"; |
142 | print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; |
144 | print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; |
143 | print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; |
145 | print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; |
144 | |
146 | |
145 | $cv = AE::cv; |
147 | $cv = AE::cv; |
146 | $wt = AE::timer 0.1, 0, $cv; |
148 | $wt = AE::timer 0.01, 0, $cv; |
147 | |
149 | |
148 | $s = 0; |
150 | $s = 0; |
149 | $cv->recv; |
151 | $cv->recv; |
150 | |
152 | |
151 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |
153 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |