Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/usr/bin/env perl |
2 | use strict; | |
3 | use warnings; | |
4 | use LWP::Simple; | |
5 | use threads; # ('exit' => 'threads_only'); | |
6 | ||
7 | sub alrm_sleep { | |
8 | my $thr = threads->create(sub { | |
9 | $SIG{'TERM'} = sub { | |
10 | threads->exit(0); | |
11 | }; | |
12 | } | |
13 | $SIG{'ALRM'} = sub { | |
14 | $thr->kill('TERM'); | |
15 | } | |
16 | alarm(3); | |
17 | $thr->join(); | |
18 | } | |
19 | ||
20 | my $thr = threads->create(sub { | |
21 | $SIG{'KILL'} = sub { | |
22 | print("thread is dying\n"); | |
23 | threads->exit(); | |
24 | }; | |
25 | ||
26 | print("new thread\n"); | |
27 | getprint('http://192.168.2.1:2/'); | |
28 | print("thread end\n"); | |
29 | }); | |
30 | ||
31 | $thr->kill('SIGKILL'); | |
32 | print("killed thread"); | |
33 | $thr->join(); |