X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftry.pl;fp=samples%2Ftry.pl;h=68388c8e02b4d938dac434822a7c061bfb29cdcb;hb=ddcc7c395d570f0ea20a8e9a242fcbfcc0e49522;hp=0000000000000000000000000000000000000000;hpb=13c16aeec1454ae58e932b393e827d6353c13231;p=perl%2Fmodules%2FIPC-MorseSignals.git diff --git a/samples/try.pl b/samples/try.pl new file mode 100755 index 0000000..68388c8 --- /dev/null +++ b/samples/try.pl @@ -0,0 +1,32 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use POSIX qw/pause EXIT_SUCCESS EXIT_FAILURE/; + +use lib qw{blib/lib}; + +use IPC::MorseSignals::Emitter; +use IPC::MorseSignals::Receiver; + +my $pid = fork; +if (!defined $pid) { + die "fork() failed : $!"; +} elsif ($pid == 0) { + local %SIG; + my $rcv = new IPC::MorseSignals::Receiver \%SIG, done => sub { + print STDERR "I, the child, recieved this : $_[1]\n"; + exit EXIT_SUCCESS; + }; + print STDERR "I'm $$ (the child), and I'm waiting for data...\n"; + pause while 1; + exit EXIT_FAILURE; +} + +print STDERR "I'm $$ (the parent), and I'm gonna send a message to my child $pid.\n"; + +my $snd = new IPC::MorseSignals::Emitter speed => 1000; +$snd->post("This message was sent with IPC::MorseSignals"); +$snd->send($pid); +waitpid $pid, 0;