2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
11 die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/;
12 $send = ($mode eq "s");
14 $id = msgget(0x1234, ($send ? 0 : &IPC_CREAT) | 0644);
15 die "Can't get message queue: $!\n" unless defined($id);
16 print "message queue id: $id\n";
21 unless (msgsnd($id, pack("LA*", $., $_), 0)) {
22 die "Can't send message: $!\n";
27 $SIG{'INT'} = $SIG{'QUIT'} = "leave";
29 unless (msgrcv($id, $_, 512, 0, 0)) {
30 die "Can't receive message: $!\n";
32 ($type, $message) = unpack("La*", $_);
33 printf "[%d] %s\n", $type, $message;
41 $x = msgctl($id, &IPC_RMID, 0);
42 if (!defined($x) || $x < 0) {
43 die "Can't remove message queue: $!\n";