X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftryityourself.pl;h=3e7dfa74a80d1d057bfd46bc8a1e2b82c762c478;hb=8a4a3ba553f81cfdb679c19363f514efb04f29c1;hp=94b90de13c7c5e91969fb9a16af1783dc61eefdb;hpb=3cadc28babc49dbbb76ef7ff7344add68f59c3c2;p=perl%2Fmodules%2FIPC-MorseSignals.git diff --git a/samples/tryityourself.pl b/samples/tryityourself.pl index 94b90de..3e7dfa7 100755 --- a/samples/tryityourself.pl +++ b/samples/tryityourself.pl @@ -11,10 +11,15 @@ my $pid = fork; if (!defined $pid) { die "fork() failed : $!"; } elsif ($pid == 0) { - local @SIG{qw/USR1 USR2/} = mrecv sub { print STDERR "recieved: $_[0]"; exit }; - print STDERR "child wait for data...\n"; + my $s = mrecv local %SIG, cb => sub { + print STDERR "I, the child, recieved this from $_[0]: $_[1]\n"; + exit + }; + print STDERR "I'm $$ (the child), and I'm waiting for data...\n"; 1 while 1; } -msend "This message was sent with IPC::MorseSignals\n" => $pid, 1000; +print STDERR "I'm $$ (the father), and I'm gonna send a message to my child $pid.\n"; + +msend "This message was sent with IPC::MorseSignals" => $pid; waitpid $pid, 0;