line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IPC::MorseSignals; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
87224
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
IPC::MorseSignals - Communicate between processes with Morse signals. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.17 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 WARNING |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Due to the POSIX signals specification (which I wasn't aware of at the time I wrote this module), this module is by nature completely unreliable and will never work properly. |
21
|
|
|
|
|
|
|
It is therefore B. |
22
|
|
|
|
|
|
|
Please don't use it (if you were actually crazy enough to use it). |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# In the sender process |
27
|
|
|
|
|
|
|
use IPC::MorseSignals::Emitter; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $deuce = IPC::MorseSignals::Emitter->new(speed => 1024); |
30
|
|
|
|
|
|
|
$deuce->post('HLAGH') for 1 .. 3; |
31
|
|
|
|
|
|
|
$deuce->send($pid); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
... |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# In the receiver process |
36
|
|
|
|
|
|
|
use IPC::MorseSignals::Receiver; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
local %SIG; |
39
|
|
|
|
|
|
|
my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub { |
40
|
|
|
|
|
|
|
print STDERR "GOT $_[1]\n"; |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This module implements a rare form of IPC by sending Morse-like signals through C and C. |
46
|
|
|
|
|
|
|
Both of those signals are used, so you won't be able to keep them for something else when you use this module. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L is a base class for emitters ; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L is a base class for receivers. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
But, seriously, use something else for your IPC. :) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CAVEATS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
When the same signal is sent several times in a row to a process, the POSIX standard does not guarantee that the relevant signal handler will be called for each of the notifications. |
65
|
|
|
|
|
|
|
This will result in malformed messages if the transfer speed is so high that the operating system does not have the time to call the signal handler for each bit. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
You need the complete L distribution. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L (standard since perl 5), L (idem) and L (since perl 5.7.3) are also required. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L, L. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L, L, L. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L for information about signals in perl. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
For truly useful IPC, search for shared memory, pipes and semaphores. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Vincent Pit, C<< >>, L. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
You can contact me by mail or on C (vincent). |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 BUGS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. |
92
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
perldoc IPC::MorseSignals |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Thanks for the inspiration, mofino ! I hope this module will fill all your IPC needs. :) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright 2007,2008,2013,2017 Vincent Pit, all rights reserved. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
109
|
|
|
|
|
|
|
under the same terms as Perl itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; # End of IPC::MorseSignals |