diff options
Diffstat (limited to 'gnu/usr.bin/perl/eg/sysvipc')
-rw-r--r-- | gnu/usr.bin/perl/eg/sysvipc/README | 9 | ||||
-rw-r--r-- | gnu/usr.bin/perl/eg/sysvipc/ipcmsg | 47 | ||||
-rw-r--r-- | gnu/usr.bin/perl/eg/sysvipc/ipcsem | 46 | ||||
-rw-r--r-- | gnu/usr.bin/perl/eg/sysvipc/ipcshm | 50 |
4 files changed, 0 insertions, 152 deletions
diff --git a/gnu/usr.bin/perl/eg/sysvipc/README b/gnu/usr.bin/perl/eg/sysvipc/README deleted file mode 100644 index 54094f1d85b..00000000000 --- a/gnu/usr.bin/perl/eg/sysvipc/README +++ /dev/null @@ -1,9 +0,0 @@ -FYEnjoyment, here are the test scripts I used while implementing SysV -IPC in Perl. Each of them must be run with the parameter "s" for -"send" or "r" for "receive"; in each case, the receiver is the server -and the sender is the client. - --- -Chip Salzenberg at ComDev/TCT <chip@tct.uucp>, <uunet!ateng!tct!chip> - - diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcmsg b/gnu/usr.bin/perl/eg/sysvipc/ipcmsg deleted file mode 100644 index 646d8b6aed6..00000000000 --- a/gnu/usr.bin/perl/eg/sysvipc/ipcmsg +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/perl -eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - -require 'sys/ipc.ph'; -require 'sys/msg.ph'; - -$| = 1; - -$mode = shift; -die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/; -$send = ($mode eq "s"); - -$id = msgget(0x1234, ($send ? 0 : &IPC_CREAT) | 0644); -die "Can't get message queue: $!\n" unless defined($id); -print "message queue id: $id\n"; - -if ($send) { - while (<STDIN>) { - chop; - unless (msgsnd($id, pack("LA*", $., $_), 0)) { - die "Can't send message: $!\n"; - } - } -} -else { - $SIG{'INT'} = $SIG{'QUIT'} = "leave"; - for (;;) { - unless (msgrcv($id, $_, 512, 0, 0)) { - die "Can't receive message: $!\n"; - } - ($type, $message) = unpack("La*", $_); - printf "[%d] %s\n", $type, $message; - } -} - -&leave; - -sub leave { - if (!$send) { - $x = msgctl($id, &IPC_RMID, 0); - if (!defined($x) || $x < 0) { - die "Can't remove message queue: $!\n"; - } - } - exit; -} diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcsem b/gnu/usr.bin/perl/eg/sysvipc/ipcsem deleted file mode 100644 index e0dc551bc5f..00000000000 --- a/gnu/usr.bin/perl/eg/sysvipc/ipcsem +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - -require 'sys/ipc.ph'; -require 'sys/msg.ph'; - -$| = 1; - -$mode = shift; -die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/; -$signal = ($mode eq "s"); - -$id = semget(0x1234, 1, ($signal ? 0 : &IPC_CREAT) | 0644); -die "Can't get semaphore: $!\n" unless defined($id); -print "semaphore id: $id\n"; - -if ($signal) { - while (<STDIN>) { - print "Signalling\n"; - unless (semop($id, pack("sss", 0, 1, 0))) { - die "Can't signal semaphore: $!\n"; - } - } -} -else { - $SIG{'INT'} = $SIG{'QUIT'} = "leave"; - for (;;) { - unless (semop($id, pack("sss", 0, -1, 0))) { - die "Can't wait for semaphore: $!\n"; - } - print "Unblocked\n"; - } -} - -&leave; - -sub leave { - if (!$signal) { - $x = semctl($id, 0, &IPC_RMID, 0); - if (!defined($x) || $x < 0) { - die "Can't remove semaphore: $!\n"; - } - } - exit; -} diff --git a/gnu/usr.bin/perl/eg/sysvipc/ipcshm b/gnu/usr.bin/perl/eg/sysvipc/ipcshm deleted file mode 100644 index f7a2bbbb36b..00000000000 --- a/gnu/usr.bin/perl/eg/sysvipc/ipcshm +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - -require 'sys/ipc.ph'; -require 'sys/shm.ph'; - -$| = 1; - -$mode = shift; -die "usage: ipcshm {r|s}\n" unless $mode =~ /^[rs]$/; -$send = ($mode eq "s"); - -$SIZE = 32; -$id = shmget(0x1234, $SIZE, ($send ? 0 : &IPC_CREAT) | 0600); -die "Can't get shared memory: $!\n" unless defined($id); -print "shared memory id: $id\n"; - -if ($send) { - while (<STDIN>) { - chop; - unless (shmwrite($id, pack("La*", length($_), $_), 0, $SIZE)) { - die "Can't write to shared memory: $!\n"; - } - } -} -else { - $SIG{'INT'} = $SIG{'QUIT'} = "leave"; - for (;;) { - $_ = <STDIN>; - unless (shmread($id, $_, 0, $SIZE)) { - die "Can't read shared memory: $!\n"; - } - $len = unpack("L", $_); - $message = substr($_, length(pack("L",0)), $len); - printf "[%d] %s\n", $len, $message; - } -} - -&leave; - -sub leave { - if (!$send) { - $x = shmctl($id, &IPC_RMID, 0); - if (!defined($x) || $x < 0) { - die "Can't remove shared memory: $!\n"; - } - } - exit; -} |