Hello all,
                Can some one point me to some detail docoument/examples of
perl IPC?. I have looked at man perlipc. But that dosent speak much
about my requirements. I got some example for the same in perl distribution
(eg/sysvipc/ipcshm). When I run the script it reported as follows

%ipcshm s
Prototype mismatch: sub main::__need_size_t vs () at (eval 67) line 1.
Can't get shared memory: No such file or directory

What may be the problem?

I have appended the script bellow

Thanks in advance

Regards,
A.Johnson
==========================================================================
#!/usr/bin/perl

push(@INC,'/usr/lib/perl5/5.00503/i386-linux');

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) | 0644);
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;
}
========================================================================


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to