Created
June 10, 2013 13:50
-
-
Save xtetsuji/5748857 to your computer and use it in GitHub Desktop.
Compare AnyEvnet->signal with %SIG about calback argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use AnyEvent; | |
| use Data::Dumper; | |
| my $cv = AnyEvent->condvar; | |
| my $ae_signal_term = AnyEvent->signal( | |
| signal => "TERM", cb => sub { | |
| my @arg = @_; | |
| print "callback arguments are " . Dumper(\@arg); | |
| }, | |
| ); | |
| $cv->recv(); | |
| exit; | |
| __END__ | |
| Execution sample: | |
| $ perl ae-signal.pl & | |
| $ kill -TERM %2 | |
| callback arguments are $VAR1 = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Data::Dumper; | |
| $SIG{TERM} = sub { | |
| my @arg = @_; | |
| print "callback arguments are " . Dumper(\@arg); | |
| }; | |
| sleep 1 while 1; | |
| exit; | |
| __END__ | |
| Execution sample: | |
| $ perl sig-signal.pl & | |
| $ kill -TERM %2 | |
| callback arguments are $VAR1 = [ | |
| 'TERM' | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment